Submission #599293

#TimeUsernameProblemLanguageResultExecution timeMemory
599293PlurmIntergalactic ship (IZhO19_xorsum)C++11
12 / 100
820 ms1960 KiB
#include <bits/stdc++.h> using namespace std; int a[1024]; int qs[1024]; int qqs[1024]; int qqss[1024]; const int MOD = 1e9 + 7; int main() { int n; scanf("%d", &n); for (int i = 1; i <= n; i++) { scanf("%d", a + i); } int q; scanf("%d", &q); vector<tuple<int, int, int>> updates; for (int i = 0; i < q; i++) { int l, r, x; scanf("%d%d%d", &l, &r, &x); updates.push_back({l, r, x}); } if (q <= 20) { int ans = 0; int last = 0; for (int bit = 0; bit < (1 << q); bit++) { for (int i = 0; i < q; i++) { if ((bit ^ last) & (1 << i)) { int l, r, x; tie(l, r, x) = updates[i]; for (int i = l; i <= r; i++) { a[i] ^= x; } } } for (int i = 1; i <= n; i++) { qs[i] = (qs[i - 1] + a[i]) % MOD; } for (int i = 1; i <= n; i++) { qqs[i] = (qqs[i - 1] + qs[i]) % MOD; qqss[i] = (qqss[i - 1] + 1ll * qs[i] * qs[i] % MOD) % MOD; } for (int i = 1; i <= n; i++) { int k = (qqss[n] + MOD - qqss[i - 1]) % MOD + (MOD - (2ll * qs[i - 1] * (qqs[n] - qqs[i - 1]) % MOD)) % MOD + 1ll * (n - i + 1) * qs[i - 1] % MOD * qs[i - 1] % MOD; ans += k; ans %= MOD; } last = bit; } printf("%d\n", ans); } return 0; }

Compilation message (stderr)

xorsum.cpp: In function 'int main()':
xorsum.cpp:11:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |   scanf("%d", &n);
      |   ~~~~~^~~~~~~~~~
xorsum.cpp:13:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |     scanf("%d", a + i);
      |     ~~~~~^~~~~~~~~~~~~
xorsum.cpp:16:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |   scanf("%d", &q);
      |   ~~~~~^~~~~~~~~~
xorsum.cpp:20:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |     scanf("%d%d%d", &l, &r, &x);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~
#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...