Submission #992886

#TimeUsernameProblemLanguageResultExecution timeMemory
992886Ice_manIntergalactic ship (IZhO19_xorsum)C++14
17 / 100
2061 ms10844 KiB
/** ____ ____ ____ __________________ ____ ____ ____ ||I || ||c || ||e || || || ||M || ||a || ||n || ||__|| ||__|| ||__|| ||________________|| ||__|| ||__|| ||__|| |/__\| |/__\| |/__\| |/________________\| |/__\| |/__\| |/__\| */ #include <iostream> #include <chrono> #include <stack> #include <vector> #define endl '\n' #define maxn 1000005 #define maxlog 20 #define INF 1000000010 #define LINF 1000000000000000005 #define mod (int)(1e9 + 7) #define endl '\n' #define pb(x) push_back(x) #define X first #define Y second #define control cout<<"passed"<<endl; #pragma GCC optimize("O3" , "Ofast" , "unroll-loops" , "fast-math") #pragma GCC target("avx2") using namespace std; typedef pair <int, int> pii; typedef long long ll; typedef pair <ll, ll> pll; typedef pair <int, ll> pil; typedef pair <ll, int> pli; typedef long double ld; std::chrono::high_resolution_clock::time_point startT, currT; constexpr double TIME_MULT = 1; double timePassed() { using namespace std::chrono; currT = high_resolution_clock::now(); double time = duration_cast<duration<double>>(currT - startT).count(); return time * TIME_MULT; } template <typename T> T power2(T num) { return num * num; } int n, q; int a[maxn], pref[maxn]; int l[maxn], r[maxn], x[maxn]; void read() { cin >> n; for(int i = 0; i < n; i++) cin >> a[i]; cin >> q; for(int i = 0; i < q; i++) { cin >> l[i] >> r[i] >> x[i]; l[i]--; r[i]--; } } void solve() { int sum = 0; for(int mask = 0; mask < (1 << q); mask++) { for(int bit = 0; bit < q; bit++) if(mask & (1 << bit)) { pref[l[bit]] ^= x[bit]; pref[r[bit] + 1] ^= x[bit]; } for(int i = 1; i < n; i++) pref[i] ^= pref[i - 1]; for(int i = 0; i < n; i++) a[i] ^= pref[i]; int cur = 0 , pom = 0; for(int i = 0; i < n; i++) { pom = 0; for(int j = i; j < n; j++) { pom += a[j]; cur += power2(pom); cur %= mod; } } sum += cur; sum %= mod; for(int i = 0; i < n; i++) { a[i] ^= pref[i]; pref[i] = 0; } } cout << sum << endl; } void combine() { int t; cin >> t; //while(t--) //read_solve(); } int main() { /**#ifdef ONLINE_JUDGE freopen("input.in", "r", stdin); freopen("output.out", "w", stdout); #endif*/ ios_base::sync_with_stdio(false); cin.tie(nullptr); ///startT = std::chrono::high_resolution_clock::now(); read(); solve(); 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...