제출 #236214

#제출 시각아이디문제언어결과실행 시간메모리
236214VEGAnnDojave (COCI17_dojave)C++14
140 / 140
804 ms126408 KiB
#include <bits/stdc++.h> #define sz(x) ((int)x.size()) #define a3 array<int, 3> #define MP make_pair using namespace std; typedef unsigned long long ull; typedef long long ll; const int N = (1 << 20); const int oo = 2e9; unordered_map<ull, int> mem[N]; ull vl[N], ans = 0; int m, n, a[N]; mt19937_64 rnd(chrono::system_clock().now().time_since_epoch().count()); int main(){ ios_base::sync_with_stdio(0); cin.tie(0); #ifdef _LOCAL freopen("in.txt","r",stdin); #endif // _LOCAL cin >> m; n = (1 << m); if (m == 1){ cout << 2; return 0; } for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 0; i < n; i++){ int obr = ((n - 1) ^ i); if (obr < i) continue; vl[i] = rnd(); vl[obr] = ull(0) - vl[i]; } mem[0][0]++; ull sum = 0; int xr = 0; for (int i = 0; i < n; i++){ sum += vl[a[i]]; xr ^= a[i]; ans += mem[xr][sum]; mem[xr][sum]++; } cout << ull(n) * (ull(n) + 1) / 2 - ans; 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...
#Verdict Execution timeMemoryGrader output
Fetching results...