제출 #1263575

#제출 시각아이디문제언어결과실행 시간메모리
1263575tminhXORanges (eJOI19_xoranges)C++20
0 / 100
49 ms3908 KiB
#include "bits/stdc++.h"
using namespace std;

#define task ""
#define ll long long
#define endl '\n'
#define fi first
#define se second
#define vall(a) (a).begin(), (a).end()
#define sze(a) (int)a.size()
#define pii pair<int, int>
#define pll pair<ll, ll>


#define ep emplace_back
#define pb push_back
#define pf push_front


const ll mod = 1e9 + 7;
const int N = 1e6 + 5;
const ll oo = 1e18;

bool START;

int n, q, a[N];

struct BIT {
	int bit[N];
	void add(int idx, int delta) {
		for (; idx <= n; idx += idx & -idx) bit[idx] ^= delta;
	}
	int get(int idx) {
		int ans = 0;
		for (; idx > 0; idx -= idx & -idx) ans ^= bit[idx];
		return ans;
	}
	int get(int l, int r) {
		return get(r) ^ get(l - 1);
	}
} bit[2];

inline void solve() {
	while(q--) {
		int t;
		cin >> t;
		if (t == 1) {
			int i, x;
			cin >> i >> x;
			bit[i & 1].add(i, a[i]);
			a[i] = x;
			bit[i & 1].add(i, a[i]);
		}
		
		if (t == 2) {
			int l, r;
			cin >> l >> r;
			int len = (r - l + 1);
			if (!(len & 1)) {
				cout << 0;
				continue;
			}
			cout << bit[r & 1].get(l, r) << endl;
		}
	}
}


inline void input() {
    cin >> n >> q;
    for (int i = 1; i <= n; ++i) {
    	 cin >> a[i];
    	 bit[i & 1].add(i, a[i]);
    }
    return solve();
}
bool END;

int main() {
    if(fopen(task ".inp", "r")) {
        freopen(task ".inp", "r", stdin);
        freopen(task ".out", "w", stdout);
    }
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);

    input();
    
    
    cerr << endl << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << 's' << endl;
    cerr << "Memory: " << fabs ((&END - &START)) / 1048576.0 << "MB\n";
    return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

xoranges.cpp: In function 'int main()':
xoranges.cpp:81:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   81 |         freopen(task ".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
xoranges.cpp:82:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   82 |         freopen(task ".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...