답안 #464493

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
464493 2021-08-13T10:06:15 Z Itamar XORanges (eJOI19_xoranges) C++14
0 / 100
633 ms 5628 KB
using namespace std;
#include <iostream>
#include <algorithm>
#include <vector>

vector<int> odd;
vector<int> eve;
vector<int> val;
int n, q;

void fun() {
    int xo = 0;
    for (int i = 0; i < n; i += 2) {
        xo = xo ^ val[i];
        eve[i] = xo;
    }
    xo = 0;
    for (int i = 1; i < n; i += 2) {
        xo = xo ^ val[i];
        odd[i] = xo;
    }
}

int main()
{

    cin >> n;
    cin >> q;
    odd.resize(n);
    eve.resize(n);
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        val.push_back(x);

    }

    fun();
    for (int i = 0; i < q; i++) {
        int a, b, c;
        cin >> a;
        cin >> b;
        cin >> c;
        if (a == 1) {
            val[b - 1] = c;
            fun();
        }
        else {
            if ((b - c-1) % 2 == 0) {
                cout << 0 << endl;
            }
            else {
                if (b == 1) {
                    cout << eve[(c - 1) ];
                }
                else if
                    ((b - 1) % 2 == 0) {
                    int x = (eve[(b - 3)]) ^ (eve[(c - 1)]);
                    cout << x << endl;
                }
                else if (b == 2) {
                    
                    cout << odd[(c - 1)] << endl;
                } else{
                    int x = odd[(b - 3)] ^ odd[(c-1)];
                    cout << x << endl;
                }
            }
        }

    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Incorrect 1 ms 204 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 204 KB Output is correct
2 Incorrect 2 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Incorrect 1 ms 204 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 633 ms 3976 KB Output is correct
2 Incorrect 611 ms 5628 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Incorrect 1 ms 204 KB Output isn't correct
5 Halted 0 ms 0 KB -