Submission #19779

# Submission time Handle Problem Language Result Execution time Memory
19779 2016-02-25T05:33:19 Z suzy 동전 (kriii4_E) C++
5 / 100
8 ms 1212 KB
#include <stdio.h>
#include <string.h>

int d[1<<15], n;

int f(int key) {
	if(key==0) return 0;
	if(d[key]>=0) return d[key];
	int pre=0, lo=0;
	while(lo<n) {
		if( (key&(1<<lo))==0 ) { lo++; continue; }
		pre=lo;
		while( (key&(1<<lo)) && lo<n ) lo++;
		for(int i=1;i<(1<<(lo-pre));i++) {
			int flip=0;
			for(int j=pre;j<lo;j++) {
				if( (i&(1<<(j-pre))) ) flip+=(1<<j);
			}
			if(!f(key-flip)) return d[key]=1;
		}
		//printf("key = %d, lo = %d\n",key,lo);
	}
	return d[key]=0;
}

int main() {
	scanf("%d",&n);
	int res=0;
	memset(d,-1,sizeof(d));
	for(int i=0;i<(1<<n);i++) {
		if(!f(i)) res++;
	}
	printf("%d",res);
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 1212 KB Output is correct
2 Correct 0 ms 1212 KB Output is correct
3 Correct 0 ms 1212 KB Output is correct
4 Correct 0 ms 1212 KB Output is correct
5 Correct 0 ms 1212 KB Output is correct
6 Correct 0 ms 1212 KB Output is correct
7 Correct 0 ms 1212 KB Output is correct
8 Correct 0 ms 1212 KB Output is correct
9 Correct 0 ms 1212 KB Output is correct
10 Correct 0 ms 1212 KB Output is correct
11 Correct 0 ms 1212 KB Output is correct
12 Correct 0 ms 1212 KB Output is correct
13 Correct 1 ms 1212 KB Output is correct
14 Correct 2 ms 1212 KB Output is correct
15 Correct 4 ms 1212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 8 ms 1208 KB SIGSEGV Segmentation fault
2 Halted 0 ms 0 KB -