Submission #868501

#TimeUsernameProblemLanguageResultExecution timeMemory
868501KiaRezIntergalactic ship (IZhO19_xorsum)C++17
17 / 100
339 ms11356 KiB
/* IN THE NAME OF GOD */ #include <bits/stdc++.h> // #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") // #pragma GCC optimize("O3") // #pragma GCC optimize("unroll-loops") using namespace std; typedef long long ll; typedef pair<ll, ll> pll; typedef pair<int, int> pii; typedef long double ld; #define F first #define S second #define Mp make_pair #define pb push_back #define pf push_front #define size(x) ((ll)x.size()) #define all(x) (x).begin(),(x).end() #define kill(x) cout << x << '\n', exit(0); #define fuck(x) cout << "(" << #x << " , " << x << ")" << endl #define endl '\n' const int N = 1e6+23, lg = 20; ll Mod = 1e9+7; //998244353; inline ll MOD(ll a, ll mod=Mod) {a%=mod; (a<0)&&(a+=mod); return a;} inline ll poww(ll a, ll b, ll mod=Mod) { ll ans = 1; a=MOD(a, mod); while (b) { if (b & 1) ans = MOD(ans*a, mod); b >>= 1; a = MOD(a*a, mod); } return ans; } ll ans, q, n, l[N], r[N], x[N], pref[N], a[N], sum[N]; int main () { ios_base::sync_with_stdio(false), cin.tie(0); cin>>n; for(int i=1; i<=n; i++) { cin>>a[i]; } cin>>q; for(int i=1; i<=q; i++) { cin>>l[i]>>r[i]>>x[i]; } if(q > 20) kill(0); for(int mask=0; mask<(1<<q); mask++) { fill(pref, pref+n+2, 0); for(int i=1; i<=q; i++) { if((mask>>(i-1))%2 == 0) continue; pref[l[i]] ^= x[i]; pref[r[i]+1] ^= x[i]; } for(int i=1; i<=n; i++) pref[i] ^= pref[i-1]; ll tmp=0; for(int i=1; i<=n; i++) { sum[i] = sum[i-1] + (a[i]^pref[i]); tmp += sum[i]; ans = MOD(ans - 2ll*tmp*sum[i] + MOD(sum[i]*sum[i])*(n+2)); } } cout<<ans<<endl; 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...