Submission #598944

#TimeUsernameProblemLanguageResultExecution timeMemory
598944JomnoiIntergalactic ship (IZhO19_xorsum)C++17
9 / 100
2075 ms2260 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]; 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 q = 0; q < Q; q++) { if(mask & (1<<q)) { for(int i = L[q]; i <= R[q]; i++) { A[i] ^= X[q]; } } } for(int i = 1; i <= N; i++) { long long sum = 0; for(int j = i; j <= N; j++) { sum += A[j]; sum %= MOD; ans += sum * sum; ans %= MOD; } } for(int q = 0; q < Q; q++) { if(mask & (1<<q)) { for(int i = L[q]; i <= R[q]; i++) { A[i] ^= X[q]; } } } } 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...