Submission #979408

#TimeUsernameProblemLanguageResultExecution timeMemory
979408MDarioIntergalactic ship (IZhO19_xorsum)C++11
0 / 100
2084 ms6228 KiB
#pragma GCC optimize("Ofast") #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define ll long long #define all(x) (x).begin(),(x).end() #define MOD 1000000007 using namespace std; using namespace __gnu_pbds; typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> TREE; ll sum(ll in,ll fi,vector<ll> a){ ll su = 0; for(int i = in; i <= fi; i++){ su += a[i]; su %= MOD; } return su; } ll K(vector<ll> a){ ll n = a.size(); ll su = 0; for(int i = 0; i < n; i++){ for(int j = i; j < n; j++){ su+= (sum(i,j,a) * sum(i,j,a))%MOD; su %= MOD; } } return su; } int main() { int n; cin >> n ; vector<ll> a(n); for(int i =0; i < n; i++){ cin >> a[i]; } int q; cin >> q; vector<pair<pair<ll,ll>,ll>> act(q); for(int i = 0; i < q; i++){ cin >> act[i].first.first >> act[i].first.second >> act[i].second; } ll su = 0; for(int i = 0 ; i < (1ll <<q); i++){ vector<ll> temp = a; for(int j = 0; j < q; j++){ if(i & (1ll << j)){ for(ll i = act[j].first.first-1; i <= act[j].first.second-1; i++){ temp[j] ^= act[j].second; } } } su += K(temp); su %= MOD; } cout << su << 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...