Submission #634058

# Submission time Handle Problem Language Result Execution time Memory
634058 2022-08-23T18:16:06 Z GordonRemzi007 XORanges (eJOI19_xoranges) C++17
0 / 100
1000 ms 1576 KB
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main() {
	int n, q, t1, t2;
	vector<int> a;
	string output;
	cin >> n;
	cin >> q;
	a.reserve(n);
	for (int i = 0; i < n; i++) {
		cin >> t1;
		a.push_back(t1);
	}
	for (int i = 0; i < q; i++) {
		cin >> t1;
		if (t1 == 1) {
			cin >> t1;
			cin >> t2;
			a[t1-1] = t2;
		}
		else {
			cin >> t1;
			cin >> t2;
			t1--;
			vector<int> b(t2-t1, 0);
			int res = 0;
			for (int i = 1; i <= t2 - t1; i++) {
				for (int j = t1; j < t2; j++) {
					b[j - t1] += i;
					if (j - i + 1 < t1) b[j - t1] -= abs(j - i + 1);
					if (j + i - 1 > t2-1) b[j - t1] -= abs(j + i - t2);
				}
			}
			for (int i = 0; i < b.size(); i++) {
				if (b[i] % 2) res = res ^ a[i + t1];
			}
			output.append(to_string(res) + "\n");
		}
	}
	cout << output;
}

Compilation message

xoranges.cpp: In function 'int main()':
xoranges.cpp:38:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |    for (int i = 0; i < b.size(); i++) {
      |                    ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 27 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1086 ms 1576 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -