Submission #530856

#TimeUsernameProblemLanguageResultExecution timeMemory
530856abc864197532Intergalactic ship (IZhO19_xorsum)C++17
17 / 100
2072 ms2236 KiB
#include <bits/stdc++.h> using namespace std; #define lli long long int #define mp make_pair #define eb emplace_back #define pb push_back #define pii pair<int,int> #define X first #define Y second #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() void abc() {cout << endl;} template <typename T, typename ...U> void abc(T i, U ...j) { cout << i << ' ', abc(j...); } template <typename T> void printv(T l, T r) { for (; l != r; ++l) cout << *l << " \n"[l + 1 == r]; } #ifdef Doludu #define test(x...) abc("[" + string(#x) + "]", x); #define owo freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout) #else #define test(x...) void(0) #define owo ios::sync_with_stdio(false) #endif const int mod = 1e9 + 7, N = 200000; int main () { owo; int n, q; cin >> n; vector <int> a(n); for (int i = 0; i < n; ++i) cin >> a[i]; cin >> q; vector <array <int, 3>> updates(q); for (int i = 0; i < q; ++i) { cin >> updates[i][0] >> updates[i][1] >> updates[i][2]; --updates[i][0]; } lli ans = 0; for (int s = 0; s < 1 << q; ++s) { vector <int> b = a; for (int i = 0; i < q; ++i) if (s >> i & 1) { for (int j = updates[i][0]; j < updates[i][1]; ++j) b[j] ^= updates[i][2]; } for (int i = 1; i < n; ++i) (b[i] += b[i - 1]) %= mod; lli pre_sq = 0, pre_sum = 0; for (int i = 0; i < n; ++i) { (pre_sq += b[i] * b[i]) %= mod; (pre_sum += b[i]) %= mod; } (ans += pre_sq * (n + 1) + mod - pre_sum * pre_sum % mod) %= mod; } cout << ans << endl; }
#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...