Submission #330777

# Submission time Handle Problem Language Result Execution time Memory
330777 2020-11-26T14:36:09 Z vitkishloh228 Intergalactic ship (IZhO19_xorsum) C++14
0 / 100
2000 ms 6940 KB
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#define int long long
const int inf = 1e9 + 7;
int32_t main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int& i : a) cin >> i;
    int q;
    cin >> q;
    vector<vector<int>> vals;
    vector<vector<int>> query(n);
    for (int i = 0; i < q; ++i) {
        int l, r, x;
        cin >> l >> r >> x;
        --l, r--;
        vals.push_back({ l,r,x });
        for (int j = l; j <= r; ++j) {
            query[j].push_back(x);
        }
    }
    int ans = 0;
    if (q <= 20) {
        for (int mask = 0; mask < (1 << q); ++mask) {
            vector<int> open(n + 1), close(n + 1);
            for (int i = 0; i < q; ++i) {
                if ((mask & (1 << i))) {
                    open[vals[i][0]] ^= vals[i][2];
                    close[vals[i][1] + 1] ^= vals[i][2];
                }
            }
            vector<int> pr(n + 1);
            int cur = open[0];
            for (int i = 0; i < n; ++i) {
                cur ^= open[i + 1];
                int R = a[i] ^ cur;
                pr[i + 1] = pr[i] + R;
                pr[i + 1] %= inf;
                cur ^= close[i + 1];
            }
            for (int i = 0; i < n; ++i) {
                for (int j = i; j < n; ++j) {
                    int sum = pr[j + 1] - pr[i];
                    if (sum < 0) sum += inf;
                    sum = (sum * sum) % inf;
                    ans += sum;
                    ans %= inf;
                }
            }
        }
        cout << ans;
        return 0;
    }
    for (int i = 0; i < n; ++i) {
        int cur = 0;
        if (query[i].size()) {
            cur ^= query[i][0];
        }
        int C = (n - i - 1) * i;
        C %= inf;
        C *= (1 << (q - 1));
        C %= inf;
        ans += (1 + ((a[i] ^ cur) * C) % inf) % inf;
        cur = 0;
        ans += (1 + ((a[i] ^ cur) * C) % inf) % inf;
    }
    cout << ans;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Incorrect 1 ms 364 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Incorrect 1 ms 364 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 72 ms 6940 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2075 ms 364 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2075 ms 364 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Incorrect 1 ms 364 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Incorrect 1 ms 364 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Incorrect 1 ms 364 KB Output isn't correct
4 Halted 0 ms 0 KB -