Submission #19402170
Source Code Expand
Copy
#include <iostream> #include <algorithm> #include <vector> #include <string> #include <utility> #include <set> #include <map> #include <cmath> #include <queue> #include <cstdio> #include <limits> #include <cstdlib> #define rep(i,n) for(int i = 0; i < n; ++i) #define rep1(i,n) for(int i = 1; i <= n; ++i) using namespace std; template<class T>bool chmax(T &a, const T &b) { if(a < b){ a = b; return 1; } return 0; } template<class T>bool chmin(T &a, const T &b) { if(a > b){ a = b; return 1; } return 0; } template<class T> inline int sz(T &a) { return a.size(); } using ll = long long; using ld = long double; using pi = pair<int,int>; using pl = pair<ll,ll>; using vi = vector<int>; using vvi = vector<vi>; using vl = vector<ll>; using vvl = vector<vl>; const int inf = numeric_limits<int>::max(); const ll infll = numeric_limits<ll>::max(); int main() { int h,w; cin >> h >> w; vector<string> s(h); rep(i,h) cin >> s[i]; vi p(h); vi f(h, 0); vi cen(h, 0); auto rec = [&](auto self, int id, int cnt)->void { if(cnt == h/2) { vector<vector<char>> t(h, vector<char>(w)); rep(j,w) { rep(i,h) { t[i][j] = s[p[i]][j]; } } bool center = true; vi ff(w,0); rep(i,w) { rep(j,w) { if(i >= j) continue; if(ff[i] || ff[j]) continue; bool flag = true; rep(k,h) { if(t[k][i] != t[h-1-k][j]) { flag = false; break; } } if(flag) { ff[i] = 1; ff[j] = 1; break; } } if(!ff[i]) { if(w % 2 == 0) break; else { bool ffff = true; rep(k,h) if(t[k][i] != t[h-1-k][i]) ffff = false; if(ffff && center) { center = false; ff[i] = 1; } } } } bool fff = true; rep(i,w) { fff &= ff[i]; } if(fff) { cout << "YES" << "\n"; exit(0); } return ; } while(f[id] || cen[id]) id++; p[cnt] = id; f[id] = 1; for (int i = id+1; i < h; i++) { if(f[i] || cen[i]) continue; p[h-1-cnt] = i; f[i] = 1; self(self, id, cnt+1); f[i] = 0; } f[id] = 0; }; if(h % 2 == 0) { rec(rec, 0, 0); cout << "NO\n"; } else { rep(i,h) { cen[i] = 1; p[h/2] = i; rec(rec, 0, 0); cen[i] = 0; } cout << "NO\n"; } return 0; }
Submission Info
Submission Time | |
---|---|
Task | E - Symmetric Grid |
User | kkktym |
Language | C++ (GCC 9.2.1) |
Score | 700 |
Code Size | 2640 Byte |
Status | AC |
Exec Time | 24 ms |
Memory | 3644 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 700 / 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 | 8 ms | 3564 KB |
10.txt | AC | 2 ms | 3424 KB |
100.txt | AC | 3 ms | 3480 KB |
11.txt | AC | 3 ms | 3504 KB |
12.txt | AC | 7 ms | 3504 KB |
13.txt | AC | 5 ms | 3636 KB |
14.txt | AC | 13 ms | 3484 KB |
15.txt | AC | 15 ms | 3612 KB |
16.txt | AC | 14 ms | 3512 KB |
17.txt | AC | 17 ms | 3608 KB |
18.txt | AC | 6 ms | 3432 KB |
19.txt | AC | 21 ms | 3640 KB |
2.txt | AC | 2 ms | 3432 KB |
20.txt | AC | 12 ms | 3444 KB |
21.txt | AC | 16 ms | 3560 KB |
22.txt | AC | 17 ms | 3536 KB |
23.txt | AC | 16 ms | 3504 KB |
24.txt | AC | 16 ms | 3644 KB |
25.txt | AC | 7 ms | 3508 KB |
26.txt | AC | 19 ms | 3508 KB |
27.txt | AC | 16 ms | 3644 KB |
28.txt | AC | 14 ms | 3584 KB |
29.txt | AC | 6 ms | 3584 KB |
3.txt | AC | 2 ms | 3444 KB |
30.txt | AC | 22 ms | 3532 KB |
31.txt | AC | 17 ms | 3568 KB |
32.txt | AC | 4 ms | 3608 KB |
33.txt | AC | 14 ms | 3612 KB |
34.txt | AC | 18 ms | 3512 KB |
35.txt | AC | 21 ms | 3432 KB |
36.txt | AC | 14 ms | 3608 KB |
37.txt | AC | 19 ms | 3612 KB |
38.txt | AC | 15 ms | 3560 KB |
39.txt | AC | 19 ms | 3612 KB |
4.txt | AC | 2 ms | 3428 KB |
40.txt | AC | 23 ms | 3644 KB |
41.txt | AC | 20 ms | 3480 KB |
42.txt | AC | 18 ms | 3608 KB |
43.txt | AC | 18 ms | 3640 KB |
44.txt | AC | 8 ms | 3568 KB |
45.txt | AC | 18 ms | 3644 KB |
46.txt | AC | 10 ms | 3612 KB |
47.txt | AC | 20 ms | 3504 KB |
48.txt | AC | 13 ms | 3448 KB |
49.txt | AC | 24 ms | 3484 KB |
5.txt | AC | 2 ms | 3480 KB |
50.txt | AC | 21 ms | 3508 KB |
51.txt | AC | 14 ms | 3508 KB |
52.txt | AC | 15 ms | 3640 KB |
53.txt | AC | 15 ms | 3480 KB |
54.txt | AC | 2 ms | 3608 KB |
55.txt | AC | 2 ms | 3448 KB |
56.txt | AC | 14 ms | 3484 KB |
6.txt | AC | 2 ms | 3604 KB |
7.txt | AC | 2 ms | 3484 KB |
8.txt | AC | 3 ms | 3488 KB |
9.txt | AC | 2 ms | 3536 KB |
sample1.txt | AC | 2 ms | 3584 KB |
sample2.txt | AC | 2 ms | 3640 KB |
sample3.txt | AC | 13 ms | 3568 KB |