Submission #2832931
Source Code Expand
#include <bits/stdc++.h> using namespace std; #define N 32 #define INF 0x3f3f3f3f string s[N],str[N],col[N],col2[N]; int hash1[N],hash2[N]; vector <string> Hash1[N<<15]; vector <string> Hash2[N<<15]; map <string,bool> vis; map <string,bool> vis2; map <char,int> cnt; map <int,int> ff; int n,m; bool check() { for(int i=1;i<=n;i++) { for(int j=0;j<m;j++) { cnt[s[i][j]]++; } } for(int i=0;i<26;i++) { ff[cnt[(char)('a'+i)]]+=cnt[(char)('a'+i)]; } int _1=0,_2=0; for(int i=1;i<200;i++) { if(ff[i]%2==0)_2++; else { _1++; } } if(n*m%2==0) { //printf("%d\n",_1); if(_1>0)return true; else return false; } else { if(_1>1)return true; else return false; } } int main() { //freopen("qc.in","r",stdin); scanf("%d%d",&n,&m); for(int i=1;i<=n;i++) { cin>>s[i]; for(int j=0;j<m;j++) { hash1[i]+=s[i][j]; } Hash1[hash1[i]].push_back(s[i]); } if(check()) { puts("NO"); return 0; } int cnt1=0,cnt2=0; for(int i=1;i<=n;i++) { if(Hash1[hash1[i]].size()%2==0)cnt2++; else cnt1++; } if(cnt1>=2) { puts("NO"); return 0; } if(n%2==1) { for(int i=1;i<=n;i++) { if(Hash1[hash1[i]].size()%2==1) { str[n/2+1]=Hash1[hash1[i]][0]; Hash1[hash1[i]].erase(Hash1[hash1[i]].begin()); break; } } } int t=1; for(int i=1;i<=n;i++) { int len=Hash1[hash1[i]].size(); for(int j=0;j<len;j++) { if(vis[Hash1[hash1[i]][j]])continue; vis[Hash1[hash1[i]][j]]=1; str[t]=Hash1[hash1[i]][j]; str[n-t+1]=Hash1[hash1[i]][len-j-1]; vis[Hash1[hash1[i]][len-j-1]]=1; t++; } } /*for(int i=1;i<=n;i++) { cout<<str[i]<<endl; } puts("");*/ for(int j=1;j<=m;j++) { for(int i=1;i<=n;i++) { col[j]=col[j]+str[i][j-1]; } } /*for(int j=1;j<=m;j++) { cout<<col[j]<<endl; } puts("");*/ for(int j=1;j<=m;j++) { for(int i=0;i<n;i++) { hash2[j]+=col[j][i]; } Hash2[hash2[j]].push_back(col[j]); } cnt1=0,cnt2=0; for(int i=1;i<=m;i++) { if(Hash2[hash2[i]].size()%2==0)cnt2++; else cnt1++; } if(cnt1>=2) { puts("NO"); return 0; } if(m%2==1) { for(int i=1;i<=m;i++) { if(Hash2[hash2[i]].size()%2==1) { col2[n/2+1]=Hash2[hash2[i]][0]; Hash2[hash2[i]].erase(Hash2[hash2[i]].begin()); break; } } } t=1; for(int i=1;i<=m;i++) { int len=Hash2[hash2[i]].size(); for(int j=0;j<len;j++) { if(vis2[Hash2[hash2[i]][j]])continue; vis2[Hash2[hash2[i]][j]]=1; col2[t]=Hash2[hash2[i]][j]; col2[m-t+1]=Hash2[hash2[i]][len-j-1]; vis2[Hash2[hash2[i]][len-j-1]]=1; t++; } } /*for(int i=1;i<=m;i++) { cout<<col2[i]<<endl; }*/ /*for(int i=1;i<=m;i++) { for(int j=0;j<n;j++) { if(col2[i][j]!=col2[m-i+1][n-j-1]) { //printf("<%d,%d>[%c]<%d,%d>[%c]\n",i,j,col2[i][j],m-i+1,n-j-1,col2[m-i+1][n-j-1]); puts("NO"); return 0; } } }*/ puts("YES"); return 0; }
Submission Info
Submission Time | |
---|---|
Task | E - Symmetric Grid |
User | We_R_Young |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 3043 Byte |
Status | WA |
Exec Time | 19 ms |
Memory | 49536 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:51:21: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d%d",&n,&m); ^
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 700 | ||||||
Status |
|
|
Set Name | Test Cases |
---|---|
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 |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
1.txt | AC | 18 ms | 49408 KB |
10.txt | AC | 18 ms | 49408 KB |
100.txt | WA | 18 ms | 49408 KB |
11.txt | AC | 18 ms | 49408 KB |
12.txt | AC | 18 ms | 49408 KB |
13.txt | AC | 18 ms | 49536 KB |
14.txt | AC | 18 ms | 49408 KB |
15.txt | AC | 19 ms | 49408 KB |
16.txt | AC | 18 ms | 49408 KB |
17.txt | AC | 19 ms | 49408 KB |
18.txt | AC | 18 ms | 49408 KB |
19.txt | AC | 18 ms | 49408 KB |
2.txt | AC | 18 ms | 49408 KB |
20.txt | AC | 18 ms | 49408 KB |
21.txt | AC | 19 ms | 49408 KB |
22.txt | AC | 18 ms | 49408 KB |
23.txt | AC | 18 ms | 49408 KB |
24.txt | WA | 18 ms | 49408 KB |
25.txt | AC | 18 ms | 49408 KB |
26.txt | AC | 18 ms | 49536 KB |
27.txt | AC | 18 ms | 49408 KB |
28.txt | AC | 19 ms | 49408 KB |
29.txt | AC | 18 ms | 49408 KB |
3.txt | AC | 18 ms | 49408 KB |
30.txt | AC | 18 ms | 49408 KB |
31.txt | AC | 18 ms | 49408 KB |
32.txt | AC | 18 ms | 49408 KB |
33.txt | AC | 18 ms | 49408 KB |
34.txt | AC | 18 ms | 49408 KB |
35.txt | AC | 19 ms | 49408 KB |
36.txt | AC | 19 ms | 49408 KB |
37.txt | AC | 18 ms | 49408 KB |
38.txt | AC | 19 ms | 49408 KB |
39.txt | AC | 18 ms | 49408 KB |
4.txt | AC | 19 ms | 49408 KB |
40.txt | AC | 18 ms | 49408 KB |
41.txt | AC | 18 ms | 49408 KB |
42.txt | AC | 18 ms | 49408 KB |
43.txt | WA | 18 ms | 49408 KB |
44.txt | AC | 18 ms | 49408 KB |
45.txt | AC | 18 ms | 49408 KB |
46.txt | AC | 18 ms | 49408 KB |
47.txt | AC | 18 ms | 49408 KB |
48.txt | AC | 18 ms | 49408 KB |
49.txt | AC | 18 ms | 49408 KB |
5.txt | AC | 18 ms | 49408 KB |
50.txt | AC | 18 ms | 49408 KB |
51.txt | AC | 18 ms | 49408 KB |
52.txt | AC | 18 ms | 49408 KB |
53.txt | AC | 18 ms | 49408 KB |
54.txt | AC | 18 ms | 49408 KB |
55.txt | WA | 18 ms | 49408 KB |
56.txt | AC | 18 ms | 49408 KB |
6.txt | AC | 18 ms | 49408 KB |
7.txt | AC | 18 ms | 49408 KB |
8.txt | AC | 19 ms | 49408 KB |
9.txt | AC | 18 ms | 49408 KB |
sample1.txt | AC | 18 ms | 49408 KB |
sample2.txt | AC | 18 ms | 49408 KB |
sample3.txt | AC | 18 ms | 49408 KB |