답안 #677763

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
677763 2023-01-04T10:19:01 Z Alcabel Intergalactic ship (IZhO19_xorsum) C++17
17 / 100
2000 ms 2248 KB
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;

int add(int a, int b) {
    int res = a + b;
    if (res >= mod) {
        res -= mod;
    }
    return res;
}

int subtr(int a, int b) {
    int res = a - b;
    if (res < 0) {
        res += mod;
    }
    return res;
}

int times(int a, int b) {
    long long res = a * 1ll * b;
    if (res >= mod) {
        res %= mod;
    }
    return res;
}

void solve() {
    int n;
    cin >> n;
    vector<int> a(n), delta(n + 1);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    int q;
    cin >> q;
    vector<int> l(q), r(q), x(q);
    for (int i = 0; i < q; ++i) {
        cin >> l[i] >> r[i] >> x[i];
        --l[i], --r[i];
    }
    int ans = 0;
    for (int mask = 0; mask < (1 << q); ++mask) {
        for (int i = 0; i < q; ++i) {
            if ((mask & (1 << i)) != 0) {
                delta[l[i]] ^= x[i];
                delta[r[i] + 1] ^= x[i];
            }
        }
        for (int i = 0, cur = 0, sum = 0, sumaux = 0; i < n; ++i) {
            sumaux = subtr(sumaux, sum);
            cur ^= delta[i];
            int val = a[i] ^ cur;
            ans = add(ans, times(times(val, val), times(i + 1, n - i)));
            ans = add(ans, times(val, times(2, sumaux)));
            sum = add(sum, times(val, i + 1));
            sumaux = add(sumaux, times(times(val, i + 1), n - i));
            delta[i] = 0;
        }
        delta[n] = 0;
    }
    cout << ans << '\n';
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int T = 1;
    // cin >> T;
    while (T--) {
        solve();
    }

    return 0;
}
# 결과 실행 시간 메모리 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
# 결과 실행 시간 메모리 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 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 2 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 16 ms 2248 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2067 ms 340 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 305 ms 304 KB Output is correct
2 Correct 318 ms 300 KB Output is correct
3 Correct 322 ms 300 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 305 ms 304 KB Output is correct
2 Correct 318 ms 300 KB Output is correct
3 Correct 322 ms 300 KB Output is correct
4 Incorrect 4 ms 340 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 2 ms 212 KB Output is correct
9 Correct 305 ms 304 KB Output is correct
10 Correct 318 ms 300 KB Output is correct
11 Correct 322 ms 300 KB Output is correct
12 Incorrect 6 ms 212 KB Output isn't correct
13 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 2 ms 212 KB Output is correct
9 Correct 305 ms 304 KB Output is correct
10 Correct 318 ms 300 KB Output is correct
11 Correct 322 ms 300 KB Output is correct
12 Incorrect 4 ms 340 KB Output isn't correct
13 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 2 ms 212 KB Output is correct
9 Incorrect 16 ms 2248 KB Output isn't correct
10 Halted 0 ms 0 KB -