Submission #2412814


Source Code Expand

#include <bits/stdc++.h>
using namespace std;

int main() {
    int N;
    scanf("%d", &N);

    int a[N];
    int b[N];
    for (int i = 0; i < N; i++) scanf("%d", &a[i]);
    for (int i = 0; i < N; i++) scanf("%d", &b[i]);

    bool ans[29] = {};
    for (int i = 29; i >= 0; i--) {
        int x = 1 << (i + 1);
        for (int j = 0; j < N; j++) {
            a[j] %= x;
            b[j] %= x;
        }
        sort(b, b + N);

        for (int j = 0; j < N; j++) {
            int* pos1 = lower_bound(b, b + N, x / 2 - a[j]);
            int* pos2 = lower_bound(b, b + N, x / 2 * 2 - a[j]);
            int* pos3 = lower_bound(b, b + N, x / 2 * 3 - a[j]);
            int* pos4 = lower_bound(b, b + N, x / 2 * 4 - a[j]);
            int idx1 = distance(pos1, pos2);
            int idx2 = distance(pos3, pos4);
            ans[i] ^= (idx1 + idx2) % 2;
        }
    }

    int sum = 0;
    for (int i = 0; i < 29; i++) {
        sum += ans[i] << i;
    }
    printf("%d\n", sum);
    
    return 0;
}

Submission Info

Submission Time
Task D - Two Sequences
User atumari
Language C++14 (GCC 5.4.1)
Score 500
Code Size 1048 Byte
Status AC
Exec Time 1800 ms
Memory 1920 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:6:20: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &N);
                    ^
./Main.cpp:10:51: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     for (int i = 0; i < N; i++) scanf("%d", &a[i]);
                                                   ^
./Main.cpp:11:51: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     for (int i = 0; i < N; i++) scanf("%d", &b[i]);
                                                   ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 500 / 500
Status
AC × 4
AC × 16
Set Name Test Cases
Sample example_0, example_1, example_2, example_3
All N100000_0, N100000_1, N150000_0, N150000_1, N200000_0, N200000_1, N200000_ex_0, N200000_ex_1, example_0, example_1, example_2, example_3, rand_0, rand_1, smallrand_0, smallrand_1
Case Name Status Exec Time Memory
N100000_0 AC 808 ms 1024 KB
N100000_1 AC 809 ms 1024 KB
N150000_0 AC 1298 ms 1408 KB
N150000_1 AC 1298 ms 1408 KB
N200000_0 AC 1800 ms 1792 KB
N200000_1 AC 1786 ms 1792 KB
N200000_ex_0 AC 1659 ms 1920 KB
N200000_ex_1 AC 1658 ms 1792 KB
example_0 AC 1 ms 256 KB
example_1 AC 1 ms 256 KB
example_2 AC 1 ms 256 KB
example_3 AC 1 ms 256 KB
rand_0 AC 38 ms 256 KB
rand_1 AC 85 ms 384 KB
smallrand_0 AC 1 ms 256 KB
smallrand_1 AC 1 ms 256 KB