답안 #72237

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
72237 2018-08-26T06:16:38 Z BBBSNG(#2263, youngyojun, sebinkim, dlalswp25) 재채점 전쟁 (FXCUP3_judge) C++17
100 / 100
886 ms 10768 KB
#include <bits/stdc++.h>

using namespace std;

int K[1101010], F[1111][1111];
bool ans[505050], cnt[1101010];
int k, b, n, m;

int main()
{
	int i, j, l, s, s1, s2;
	char str[33];
	
	scanf("%d", &k);
	
	b = k / 2;
	
	scanf("%d", &n);
	
	for(i=1; i<=n; i++){
		scanf("%s", str);
		
		for(s=0, j=0; j<k; j++){
			if(str[j] != '.') s |= (1 << j);
		}
		
		K[s] |= s;
	}
	
	scanf("%d", &m);
	
	for(i=1; i<=m; i++){
		scanf("%s", str);
		
		for(s1=0, j=0; j<b; j++){
			if(str[j] != '.') s1 |= (1 << j);
		}
		
		for(s2=0, j=b; j<k; j++){
			if(str[j] != '.') s2 |= (1 << j-b);
		}
		
		F[s1][s2] ++;
	}

	for(i=0; i<(1<<k); i++){
		for(j=0; j<k; j++){
			if(i & (1 << j)) cnt[i] ^= 1;
		}
	}	
	
	for(i=0; i<(1<<b); i++){
		for(j=0; j<(1<<(k-b)); j++){
			for(l=j; l; l=(l-1)&j){
				if(cnt[l]) F[i][j] += F[i][j - l];
				else F[i][j] -= F[i][j - l];
			}
		}
	}
	
	for(i=0; i<(1<<k-b); i++){
		for(j=0; j<(1<<b); j++){
			for(l=j; l; l=(l-1)&j){
				if(cnt[l]) F[j][i] += F[j - l][i];
				else F[j][i] -= F[j - l][i];
			}
		}
	}
	
	for(i=0; i<(1<<k); i++){
		for(j=0; j<k; j++){
			if(i & (1 << j)) K[i] |= K[i - (1 << j)];
		}
		
		if(K[i] == i){
			j = (1 << k) - 1 - i;
//			printf("%d %d %d\n", i, j, F[j & ((1 << b) - 1)][j >> b]);
			ans[m - F[j & ((1 << b) - 1)][j >> b]] = 1;
		}
		
/*		for(l=0; l<k; l++){
			if(i & (1 << l)) printf("1");
			else printf("0");
		}
		printf(" %d %d\n", i, F[i & ((1 << b) - 1)][i >> b]);
*/	}
	
	for(i=1; i<=m; i++){
		printf("%c", ans[i]? 'o' : 'x');
	}
	
	printf("\n");
	
	return 0;
}

Compilation message

judge.cpp: In function 'int main()':
judge.cpp:40:35: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
    if(str[j] != '.') s2 |= (1 << j-b);
                                  ~^~
judge.cpp:61:18: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
  for(i=0; i<(1<<k-b); i++){
                 ~^~
judge.cpp:14:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &k);
  ~~~~~^~~~~~~~~~
judge.cpp:18:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
  ~~~~~^~~~~~~~~~
judge.cpp:21:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%s", str);
   ~~~~~^~~~~~~~~~~
judge.cpp:30:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &m);
  ~~~~~^~~~~~~~~~
judge.cpp:33:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%s", str);
   ~~~~~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 484 KB Output is correct
3 Correct 3 ms 536 KB Output is correct
4 Correct 13 ms 1152 KB Output is correct
5 Correct 12 ms 1316 KB Output is correct
6 Correct 12 ms 1316 KB Output is correct
7 Correct 11 ms 1316 KB Output is correct
8 Correct 11 ms 1316 KB Output is correct
9 Correct 11 ms 1316 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 484 KB Output is correct
3 Correct 3 ms 536 KB Output is correct
4 Correct 13 ms 1152 KB Output is correct
5 Correct 12 ms 1316 KB Output is correct
6 Correct 12 ms 1316 KB Output is correct
7 Correct 11 ms 1316 KB Output is correct
8 Correct 11 ms 1316 KB Output is correct
9 Correct 11 ms 1316 KB Output is correct
10 Correct 89 ms 1316 KB Output is correct
11 Correct 62 ms 1316 KB Output is correct
12 Correct 22 ms 1316 KB Output is correct
13 Correct 11 ms 1316 KB Output is correct
14 Correct 113 ms 1316 KB Output is correct
15 Correct 196 ms 1796 KB Output is correct
16 Correct 255 ms 1812 KB Output is correct
17 Correct 292 ms 1940 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 484 KB Output is correct
3 Correct 3 ms 536 KB Output is correct
4 Correct 13 ms 1152 KB Output is correct
5 Correct 12 ms 1316 KB Output is correct
6 Correct 12 ms 1316 KB Output is correct
7 Correct 11 ms 1316 KB Output is correct
8 Correct 11 ms 1316 KB Output is correct
9 Correct 11 ms 1316 KB Output is correct
10 Correct 89 ms 1316 KB Output is correct
11 Correct 62 ms 1316 KB Output is correct
12 Correct 22 ms 1316 KB Output is correct
13 Correct 11 ms 1316 KB Output is correct
14 Correct 113 ms 1316 KB Output is correct
15 Correct 196 ms 1796 KB Output is correct
16 Correct 255 ms 1812 KB Output is correct
17 Correct 292 ms 1940 KB Output is correct
18 Correct 299 ms 4472 KB Output is correct
19 Correct 326 ms 5444 KB Output is correct
20 Correct 776 ms 10712 KB Output is correct
21 Correct 623 ms 10712 KB Output is correct
22 Correct 886 ms 10768 KB Output is correct
23 Correct 856 ms 10768 KB Output is correct