Submission #599075

#TimeUsernameProblemLanguageResultExecution timeMemory
599075JomnoiIntergalactic ship (IZhO19_xorsum)C++17
17 / 100
2079 ms2252 KiB
#include <bits/stdc++.h> using namespace std; const int MAX_N = 1005; const int MAX_Q = 1e5 + 5; const int MOD = 1e9 + 7; int A[MAX_N]; long long qs[MAX_N], qs2[MAX_N]; int L[MAX_Q], R[MAX_Q], X[MAX_Q]; int main() { cin.tie(nullptr)->sync_with_stdio(false); int N; cin >> N; for(int i = 1; i <= N; i++) { cin >> A[i]; } int Q; cin >> Q; for(int i = 0; i < Q; i++) { cin >> L[i] >> R[i] >> X[i]; } long long ans = 0; for(int mask = 0; mask < (1<<Q); mask++) { for(int i = 1; i <= N; i++) { qs[i] = 0; } for(int q = 0; q < Q; q++) { if(mask & (1<<q)) { qs[L[q]] ^= X[q]; qs[R[q] + 1] ^= X[q]; } } for(int i = 1; i <= N; i++) { qs[i] ^= qs[i - 1]; qs2[i] = qs2[i - 1] + (A[i] ^ qs[i]); } long long sum2 = 0, sum1 = 0; for(int i = 1; i <= N; i++) { ans += i * qs2[i] * qs2[i] - 2 * qs2[i] * sum1 + sum2; ans %= MOD; sum1 += qs2[i]; sum1 %= MOD; sum2 += qs2[i] * qs2[i]; sum2 %= MOD; } } cout << ans; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...