Submission #634028

# Submission time Handle Problem Language Result Execution time Memory
634028 2022-08-23T17:37:02 Z antimirage XORanges (eJOI19_xoranges) C++14
75 / 100
459 ms 8800 KB
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <set>
#include <map>

using namespace std;

const int N = 1e6 + 5;

int n, q, a[N], type, l, r, pref[2][N];

main(){
    cin >> n >> q;
    for (int i = 1; i <= n; i++) {
        scanf("%d", &a[i]);
        
        pref[i & 1][i] = a[i];
        
        pref[0][i] ^= pref[0][i - 1];
        pref[1][i] ^= pref[1][i - 1];
    }
    if (n <= 5000 && q <= 5000) {
        while (q--) {
            cin >> type >> l >> r;
            if (type == 1) {
                a[l] = r;
            } else {
                if ((r - l + 1) & 1) {
                    int ans = 0;
                    for (int i = l; i <= r; i += 2) {
                        ans ^= a[i];
                    }
                    cout << ans << endl;
                } else {
                    puts("0");
                }
            }
        }
    } else {
        while (q--) {
            cin >> type >> l >> r;
            if ((r - l + 1) & 1) {
                cout << (pref[l & 1][r] ^ pref[l & 1][l - 1]) << endl;
            } else {
                puts("0");
            }
        }
    }
}

Compilation message

xoranges.cpp:14:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   14 | main(){
      | ^~~~
xoranges.cpp: In function 'int main()':
xoranges.cpp:17:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |         scanf("%d", &a[i]);
      |         ~~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 2 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 2 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 2 ms 212 KB Output is correct
11 Correct 8 ms 400 KB Output is correct
12 Correct 8 ms 340 KB Output is correct
13 Correct 13 ms 340 KB Output is correct
14 Correct 16 ms 404 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 432 ms 3816 KB Output is correct
2 Correct 412 ms 8648 KB Output is correct
3 Correct 459 ms 8800 KB Output is correct
4 Correct 423 ms 8428 KB Output is correct
5 Correct 410 ms 8304 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 2 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 2 ms 212 KB Output is correct
11 Correct 8 ms 400 KB Output is correct
12 Correct 8 ms 340 KB Output is correct
13 Correct 13 ms 340 KB Output is correct
14 Correct 16 ms 404 KB Output is correct
15 Correct 432 ms 3816 KB Output is correct
16 Correct 412 ms 8648 KB Output is correct
17 Correct 459 ms 8800 KB Output is correct
18 Correct 423 ms 8428 KB Output is correct
19 Correct 410 ms 8304 KB Output is correct
20 Runtime error 36 ms 7348 KB Execution killed with signal 11
21 Halted 0 ms 0 KB -