Submission #36860

#TimeUsernameProblemLanguageResultExecution timeMemory
36860szawinisDojave (COCI17_dojave)C++14
70 / 140
4000 ms11232 KiB
#include <bits/stdc++.h>
using namespace std;
const int N = (1 << 20) + 1;

int m, n, ans, a[N], s[N];
bool mark[N];
int main() {
	scanf("%d", &m);
	if(m == 1) printf("2"), exit(0);
	n = 1 << m;
	ans = n*(n+1) / 2;
	for(int i = 1; i <= n; i++) {
		scanf("%d", a+i);
		s[i] = s[i-1] ^ a[i];
	}
	for(int i = 1; i <= n; i++) {
		int cnt = 0;
		for(int j = i; j <= n; j++) {
			mark[a[j]] = true;
			cnt += mark[a[j] ^ (n-1)];
			if(s[j] ^ s[i-1] || (j-i+1) % 4) continue;

			if(cnt == j-i+1 >> 1) --ans;
		}
		for(int j = i; j <= n; j++) mark[a[j]] = false;
	}
	printf("%d", ans);
}

Compilation message (stderr)

dojave.cpp: In function 'int main()':
dojave.cpp:23:17: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
    if(cnt == j-i+1 >> 1) --ans;
                 ^
dojave.cpp:8:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &m);
                 ^
dojave.cpp:13:19: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", a+i);
                   ^
#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...