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 <iostream>
#include <vector>
#include <set>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <stdio.h>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <fstream>
#include <complex>
#include <stack>
#include <bitset>
#include <set>
#define FOR(i,n) for(int i=0;i<n;i++)
#define FORE(i,a,b) for(int i=a;i<=b;i++)
#define ll long long int
#define vi vector<int>
#define ii pair<ll,ll>
#define pb push_back
#define mp make_pair
#define vv vector
#define ff first
#define ss second
#define pll pair<ll,ll>
#define cd complex<double>
#define ld long double
#define pld pair<ld,ld>
#define iii pair<ii,int>
using namespace std;
const ll MOD = 998244353;
bool isV(int* arr,int n,int l,int r){
int x = 0;
int v = (1<<n)-1;
n = 1 << n;
FORE(i,l,r)x ^= arr[i];
if(x == v)return 1;
//cout << l << " " << r << " " << v << " " << x << endl;
FOR(i,n){
if(l <= i and i <= r)continue;
FOR(j,n){
if(j < l or j > r)continue;
//cout << i << " " << j << endl;
if((x^arr[i]^arr[j]) == v){
return 1;
}
}
}
cout << l+1 << " " << r+1 << " " << x << endl;
return 0;
}
#define endl '\n'
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n;
cin >> n;
int n2 = n;
n = 1<<n;
int arr[n];
FOR(i,n)cin >> arr[i];
int ctr = 0;
FOR(i,n){
FOR(j,n){
int sum = 0;
FORE(x,i,j)sum ^= arr[x];
if(i < j and sum == 0){
ctr++;
// cout << "OO : " << i+1 << " " << j+1 << endl;
}
if(i <= j){
//ctr += isV(arr,n2,i,j);
}else{
//cout << i+1 << " " << j+1 << endl;
}
}
}
ctr -= (arr[0] == 0 or arr[n-1] == 0);
//cout << ctr << endl;
cout << n*(n+1)/2 - ctr << endl;
return 0;
}
Compilation message (stderr)
dojave.cpp: In function 'int main()':
dojave.cpp:71:9: warning: unused variable 'n2' [-Wunused-variable]
int n2 = n;
^~
# | 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... |