Submission #992937

#TimeUsernameProblemLanguageResultExecution timeMemory
992937NValchanovIntergalactic ship (IZhO19_xorsum)C++17
12 / 100
2008 ms2100 KiB
#include <bits/stdc++.h> #define endl '\n' using namespace std; typedef long long ll; const int MAXN = 1e3 + 10; const int MOD = 1e9 + 7; const int MAXLOG = 10; struct upd { int left, right; int val; upd() { left = right = 1; val = 0; } upd(int _left, int _right, int _val) { left = _left; right = _right; val = _val; } }; int n, q; int a[MAXN]; int cur[MAXN]; vector < upd > updates; int ans = 0; void read() { cin >> n; for(int i = 0; i < n; i++) { cin >> a[i]; } cin >> q; for(int i = 0; i < q; i++) { int left, right; int x; cin >> left >> right >> x; upd u = upd(left - 1, right - 1, x); updates.push_back(u); } } int calc() { int qni = 0; int sum = 0; int sumsum = 0; for(int i = 0; i < n; i++) { sum = (sum + cur[i]) % MOD; sumsum = (sumsum + sum) % MOD; qni = (qni + (sum * sum) % MOD) % MOD; } return (( qni * (n + 1) ) % MOD - (sumsum * sumsum) % MOD + MOD) % MOD; } void solve() { for(int mask = 0; mask < (1 << q); mask++) { for(int i = 0; i < n; i++) { cur[i] = a[i]; } for(int j = 0; j < q; j++) { int left = updates[j].left; int right = updates[j].right; int val = updates[j].val; if(mask & (1 << j)) { for(int i = left; i <= right; i++) { cur[i] ^= val; } } } ans = (ans + calc()) % MOD; } cout << ans << endl; } int main() { ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); read(); solve(); 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...