Submission #993053

#TimeUsernameProblemLanguageResultExecution timeMemory
993053Ice_manIntergalactic ship (IZhO19_xorsum)C++14
47 / 100
2077 ms2700 KiB
/** ____ ____ ____ __________________ ____ ____ ____ ||I || ||c || ||e || || || ||M || ||a || ||n || ||__|| ||__|| ||__|| ||________________|| ||__|| ||__|| ||__|| |/__\| |/__\| |/__\| |/________________\| |/__\| |/__\| |/__\| */ #include <iostream> #include <chrono> #include <stack> #include <vector> #define endl '\n' #define maxn 100005 #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; ll 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]--; } } int pow2[maxn]; void pre() { pow2[0] = 1; for(int i = 1; i < maxn; i++) pow2[i] = pow2[i - 1] * 2 % mod; } void solve() { ll sum = 0; for(int bit1 = 0; bit1 <= 6; bit1++) for(int bit2 = 0; bit2 <= 6; bit2++) { for(int i = 0; i < n; i++) for(int j = i; j < n; j++) { ll cur = 0; int br[2][2]; br[0][0] = 0; br[0][1] = 0; br[1][0] = 0; br[1][1] = 0; int c1, c2; for(int k = 0; k < q; k++) { c1 = 0; c2 = 0; if((x[k] >> bit1 & 1) && l[k] <= i && i <= r[k]) c1 = 1; if((x[k] >> bit2 & 1) && l[k] <= j && j <= r[k]) c2 = 1; br[c1][c2]++; } if(br[1][1] != 0) { if(br[1][0] + br[0][1] != 0) cur += pow2[q - 2]; else if((a[i] >> bit1 & 1) == (a[j] >> bit2 & 1)) cur += pow2[q - 1]; } else { ll pom = 1; if(br[1][0] != 0) { pom *= pow2[br[1][0] - 1]; } else if(!(a[i] >> bit1 & 1)) { pom = 0; } if(br[0][1] != 0) { pom *= pow2[br[0][1] - 1]; } else if(!(a[j] >> bit2 & 1)) { pom = 0; } cur += pom % mod * pow2[br[0][0]] % mod; } //cout << cur << endl; if(i == j) sum += cur % mod * (1 << (bit1 + bit2)) % mod * (i + 1) * (n - j) % mod; else sum += 2 * cur % mod * (1 << (bit1 + bit2)) % mod * (i + 1) * (n - j) % mod; } } cout << sum % mod << 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(); pre(); 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...