Submission #690576

#TimeUsernameProblemLanguageResultExecution timeMemory
690576iskhakkutbilimIntergalactic ship (IZhO19_xorsum)C++14
17 / 100
2077 ms3424 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define ff first #define ss second #define all(a) a.begin(), a.end() const int N = 1000; const int M = 1e9+7; struct upd{ int l, r, x; }; vector<upd> query; int n, q, a[N]; int count_K(){ int sum = 0; for(int i = 0;i < n; i++){ int s = 0; for(int j = i;j < n; j++){ s+= a[j]; sum = (sum + s*s)%M; } } return sum; } main(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n; for(int i = 0;i < n; i++){ cin >> a[i]; } cin >> q; query.resize(q); for(int i = 0;i < q; i++){ cin >> query[i].l >> query[i].r >> query[i].x; query[i].l--, query[i].r--; } int answer = 0; for(int mask = 0; mask < (1<<q); mask++){ for(int i = 0;i < q; i++){ if(mask & (1<<i)){ for(int j = query[i].l; j <= query[i].r; j++){ a[j] = (a[j] ^ query[i].x); } } } answer = (answer + count_K())%M; for(int i = 0;i < q; i++){ if(mask & (1<<i)){ for(int j = query[i].l; j <= query[i].r; j++){ a[j] = (a[j] ^ query[i].x); } } } } cout << answer; return 0; }

Compilation message (stderr)

xorsum.cpp:28:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   28 | main(){
      | ^~~~
#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...