提出 #2352630


ソースコード 拡げる

Copy
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<set>
#include<bitset>
#include<map>

#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)

using namespace std;

typedef long long LL;
typedef double db;

int get(){
	char ch;
	while(ch=getchar(),(ch<'0'||ch>'9')&&ch!='-');
	if (ch=='-'){
		int s=0;
		while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
		return -s;
	}
	int s=ch-'0';
	while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
	return s;
}

const int L = 10395+10;
const int N = 13;
const int M = (1<<12)+1;

bitset<L>cp[N][N],f[M];
int n,m;
char s[N][N];
bool bz[N];
int tp[L][N];
int k;
int ct[N];

void dfs(int x,bool tg){
	if (x>m){
		k++;
		fo(i,1,m)tp[k][i]=ct[i];
		return;
	}
	if (bz[x]){dfs(x+1,tg);return;}
	fo(i,x+1,m)
	if (!bz[i]){
		bz[x]=bz[i]=1;
		ct[x]=i,ct[i]=x;
		dfs(x+1,tg);
		ct[x]=ct[i]=0;
		bz[x]=bz[i]=0;
	}
	if (!tg&&(m&1)>0){
		bz[x]=1;
		ct[x]=x;
		dfs(x+1,1);
		ct[x]=x;
		bz[x]=0;
	}
}

int cnt[M];

int main(){
	//freopen("data.in","r",stdin);
	n=get();m=get();
	fo(i,1,n)scanf("%s",s[i]+1);
	dfs(1,0);
	fo(i,1,n){
		fo(j,i,n){
			fo(w,1,k){
				bool pd=1;
				fo(x,1,m)pd&=(s[j][tp[w][x]]==s[i][x]);
				if (pd)cp[i][j][w-1]=1;
			}
		}
	}
	fo(i,0,k-1)f[0][i]=1;
	fo(i,1,(1<<n)-1)cnt[i]=cnt[i-(i&-i)]+1;
	fo(i,0,(1<<n)-1)
	if ((cnt[i]&1)==0&&cnt[i]<n){
		int x;
		fo(w,1,n)
		if (((1<<(w-1))&i)==0){x=w;break;}
		fo(y,x+1,n)
		if (((1<<(y-1))&i)==0)f[i|(1<<(x-1))|(1<<(y-1))]=f[i|(1<<(x-1))|(1<<(y-1))]|(f[i]&cp[x][y]);
	}
	if (n&1){
		fo(i,0,(1<<n)-1)
		if ((n-cnt[i])==1){
			int x;
			fo(w,1,n)
			if (((1<<(w-1))&i)==0){x=w;break;}
			f[(1<<n)-1]=f[(1<<n)-1]|(f[i]&cp[x][x]);
		}
	}
	bool ans=0;
	fo(i,0,k-1)ans=ans|f[(1<<n)-1][i];
	if (ans)printf("YES\n");
	else printf("NO\n");
	return 0;
}

提出情報

提出日時
問題 E - Symmetric Grid
ユーザ samjia2000
言語 C++14 (GCC 5.4.1)
得点 0
コード長 1918 Byte
結果 WA
実行時間 19 ms
メモリ 5632 KB

コンパイルエラー

./Main.cpp: In function ‘int main()’:
./Main.cpp:72:29: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  fo(i,1,n)scanf("%s",s[i]+1);
                             ^

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 0 / 700
結果
AC × 3
AC × 57
WA × 6
セット名 テストケース
Sample sample1.txt, sample2.txt, sample3.txt
All sample1.txt, sample2.txt, sample3.txt, 1.txt, 10.txt, 100.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 2.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, 29.txt, 3.txt, 30.txt, 31.txt, 32.txt, 33.txt, 34.txt, 35.txt, 36.txt, 37.txt, 38.txt, 39.txt, 4.txt, 40.txt, 41.txt, 42.txt, 43.txt, 44.txt, 45.txt, 46.txt, 47.txt, 48.txt, 49.txt, 5.txt, 50.txt, 51.txt, 52.txt, 53.txt, 54.txt, 55.txt, 56.txt, 6.txt, 7.txt, 8.txt, 9.txt, sample1.txt, sample2.txt, sample3.txt
ケース名 結果 実行時間 メモリ
1.txt WA 1 ms 256 KB
10.txt WA 4 ms 768 KB
100.txt AC 1 ms 640 KB
11.txt AC 3 ms 1408 KB
12.txt AC 3 ms 1408 KB
13.txt WA 13 ms 4096 KB
14.txt AC 17 ms 5504 KB
15.txt AC 13 ms 4096 KB
16.txt AC 18 ms 5504 KB
17.txt AC 13 ms 4096 KB
18.txt AC 17 ms 5504 KB
19.txt AC 13 ms 4096 KB
2.txt AC 1 ms 256 KB
20.txt AC 18 ms 5504 KB
21.txt AC 13 ms 4096 KB
22.txt AC 17 ms 5504 KB
23.txt AC 13 ms 4096 KB
24.txt AC 13 ms 4096 KB
25.txt AC 18 ms 5504 KB
26.txt AC 13 ms 4096 KB
27.txt AC 13 ms 4096 KB
28.txt AC 18 ms 5504 KB
29.txt AC 17 ms 5504 KB
3.txt AC 1 ms 256 KB
30.txt AC 13 ms 4096 KB
31.txt AC 12 ms 4096 KB
32.txt AC 18 ms 5504 KB
33.txt AC 13 ms 4096 KB
34.txt AC 17 ms 5504 KB
35.txt AC 17 ms 5504 KB
36.txt WA 12 ms 4096 KB
37.txt AC 18 ms 5504 KB
38.txt AC 13 ms 4096 KB
39.txt AC 13 ms 4096 KB
4.txt AC 2 ms 768 KB
40.txt AC 17 ms 5504 KB
41.txt AC 12 ms 4096 KB
42.txt AC 17 ms 5504 KB
43.txt AC 18 ms 5504 KB
44.txt WA 13 ms 4096 KB
45.txt AC 17 ms 5504 KB
46.txt WA 13 ms 4096 KB
47.txt AC 18 ms 5504 KB
48.txt AC 13 ms 4096 KB
49.txt AC 17 ms 5504 KB
5.txt AC 2 ms 768 KB
50.txt AC 13 ms 4096 KB
51.txt AC 18 ms 5504 KB
52.txt AC 18 ms 5504 KB
53.txt AC 18 ms 5504 KB
54.txt AC 19 ms 5632 KB
55.txt AC 13 ms 4224 KB
56.txt AC 18 ms 5504 KB
6.txt AC 2 ms 768 KB
7.txt AC 3 ms 768 KB
8.txt AC 3 ms 768 KB
9.txt AC 4 ms 768 KB
sample1.txt AC 1 ms 256 KB
sample2.txt AC 1 ms 256 KB
sample3.txt AC 18 ms 5504 KB