# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
168007 | rzbt | Dojave (COCI17_dojave) | C++14 | 1811 ms | 97696 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define MAXN 2000000
typedef long long ll;
using namespace std;
ll niz[MAXN];
ll m,n;
ll nu,ve;
ll bit[MAXN],dubina[MAXN];
ll nula=1,tksor,td;
ll gde[MAXN];
ll r1,r2,r3;
map<ll,ll> mpa;
ll res;
int main()
{
srand(time(NULL));
scanf("%lld", &m);
if(m==1){
printf("2");
return 0;
}
n=1ll<<m;
res=n*(n+1)/2;
for(ll i=1;i<=n;i++){
scanf("%lld",niz+i);
}
for(ll i=1;i<=n;i++){
gde[niz[i]]=i;
if(!gde[n-niz[i]-1]){
//printf(" %lld %lld %lld\n",i,niz[i],n-niz[i]-1);
r1=rand();
r2=rand();
r3=rand();
bit[i]=r1 ^(r2<<16ll)^(r3<<32ll);
}else bit[i]=(1ll<<55ll)-1ll-bit[gde[n-niz[i]-1]];
auto a=mpa.insert(mp(tksor,1ll));
if(!a.S)a.F->S++;
tksor^=bit[i];
res-=mpa[tksor];
//printf(" %lld %lld %lld\n",i,td,n-niz[i]-1);
}
printf("%lld",res);
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |