Submission #3227514
Source Code Expand
#include <bits/stdc++.h> typedef long long i64; using std::cout; using std::endl; using std::cin; std::vector<std::vector<int>> g; std::vector<std::string> s, t; int h, w; std::vector<int> vec; std::vector<bool> used; bool dfs(int n = 0) { if(n == (h + 1) / 2) { std::map<std::string, int> mp; for(int i = 0; i < w; i++) { std::string latte = ""; for(int j = 0; j < h; j++) { latte += s[vec[j]][i]; } mp[latte] += 1; reverse(begin(latte), end(latte)); mp[latte] -= 1; } for(auto p : mp) if(p.second != 0) return false; return true; } for(int i = 0; i < h; i++) { if(used[i]) continue; for(auto e : g[i]) { if(used[e]) continue; if(n != h - n - 1 and i == e) continue; vec[n] = i; vec[h - n - 1] = e; used[i] = true; used[e] = true; if(dfs(n + 1)) return true; used[i] = false; used[e] = false; } } return false; } int main(){ cin >> h >> w; s.resize(h); t.resize(h); g.resize(h); for(int i = 0; i < h; i++) { cin >> s[i]; t[i] = s[i]; sort(begin(t[i]), end(t[i])); } for(int i = 0; i < h; i++) { for(int j = 0; j < h; j++) { if(t[i] == t[j]) g[i].push_back(j); } } cout << "NO" << endl; return 0; vec.resize(h, 0); used.resize(h, false); cout << (dfs() ? "YES" : "NO") << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | E - Symmetric Grid |
User | ecasdqina |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1370 Byte |
Status | WA |
Exec Time | 1 ms |
Memory | 256 KB |
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 | WA | 1 ms | 256 KB |
10.txt | WA | 1 ms | 256 KB |
100.txt | AC | 1 ms | 256 KB |
11.txt | AC | 1 ms | 256 KB |
12.txt | AC | 1 ms | 256 KB |
13.txt | WA | 1 ms | 256 KB |
14.txt | WA | 1 ms | 256 KB |
15.txt | WA | 1 ms | 256 KB |
16.txt | AC | 1 ms | 256 KB |
17.txt | AC | 1 ms | 256 KB |
18.txt | WA | 1 ms | 256 KB |
19.txt | AC | 1 ms | 256 KB |
2.txt | WA | 1 ms | 256 KB |
20.txt | WA | 1 ms | 256 KB |
21.txt | AC | 1 ms | 256 KB |
22.txt | AC | 1 ms | 256 KB |
23.txt | AC | 1 ms | 256 KB |
24.txt | WA | 1 ms | 256 KB |
25.txt | WA | 1 ms | 256 KB |
26.txt | AC | 1 ms | 256 KB |
27.txt | AC | 1 ms | 256 KB |
28.txt | AC | 1 ms | 256 KB |
29.txt | WA | 1 ms | 256 KB |
3.txt | WA | 1 ms | 256 KB |
30.txt | WA | 1 ms | 256 KB |
31.txt | AC | 1 ms | 256 KB |
32.txt | WA | 1 ms | 256 KB |
33.txt | AC | 1 ms | 256 KB |
34.txt | AC | 1 ms | 256 KB |
35.txt | AC | 1 ms | 256 KB |
36.txt | WA | 1 ms | 256 KB |
37.txt | WA | 1 ms | 256 KB |
38.txt | AC | 1 ms | 256 KB |
39.txt | WA | 1 ms | 256 KB |
4.txt | WA | 1 ms | 256 KB |
40.txt | AC | 1 ms | 256 KB |
41.txt | AC | 1 ms | 256 KB |
42.txt | AC | 1 ms | 256 KB |
43.txt | AC | 1 ms | 256 KB |
44.txt | WA | 1 ms | 256 KB |
45.txt | WA | 1 ms | 256 KB |
46.txt | WA | 1 ms | 256 KB |
47.txt | WA | 1 ms | 256 KB |
48.txt | AC | 1 ms | 256 KB |
49.txt | AC | 1 ms | 256 KB |
5.txt | WA | 1 ms | 256 KB |
50.txt | AC | 1 ms | 256 KB |
51.txt | WA | 1 ms | 256 KB |
52.txt | AC | 1 ms | 256 KB |
53.txt | AC | 1 ms | 256 KB |
54.txt | WA | 1 ms | 256 KB |
55.txt | WA | 1 ms | 256 KB |
56.txt | AC | 1 ms | 256 KB |
6.txt | WA | 1 ms | 256 KB |
7.txt | AC | 1 ms | 256 KB |
8.txt | WA | 1 ms | 256 KB |
9.txt | AC | 1 ms | 256 KB |
sample1.txt | WA | 1 ms | 256 KB |
sample2.txt | AC | 1 ms | 256 KB |
sample3.txt | WA | 1 ms | 256 KB |