Submission #2141444
Source Code Expand
#include <bits/stdc++.h> using namespace std; const int N = 205; const int mod = 1e9 + 7; int n, m, res = 1; int par[N]; char a[N][N]; int find(int u) { return (u == par[u]) ? u : par[u] = find(par[u]); } void join(int u, int v) { par[find(u)] = find(v); } int main() { ios::sync_with_stdio(false); cin >> n >> m; for (int i = 0; i < n; ++i) { for (int j = 0; j < m; ++j) { cin >> a[i][j]; } } if (n & 1) { string s, t; for (int i = 0; i < m; ++i) { s.push_back(a[n / 2][i]); } t = s, reverse(t.begin(), t.end()); res *= (s != t) + 1; } if (m & 1) { string s, t; for (int i = 0; i < n; ++i) { s.push_back(a[i][m / 2]); } t = s, reverse(t.begin(), t.end()); res *= (s != t) + 1; } for (int i = 0; i < n / 2 + m / 2; ++i) par[i] = i; for (int i = 0; i < n / 2; ++i) { for (int j = 0; j < m / 2; ++j) { set<string> ss; vector<char> v; vector<int> p; v.push_back(a[i][j]), v.push_back(a[n - 1 - i][j]); v.push_back(a[i][m - 1 - j]), v.push_back(a[n - 1 - i][m - 1 - j]); for (int k = 0; k < 4; ++k) p.push_back(k); do { string s; for (int k = 0; k < 4; ++k) s.push_back(v[p[k]]); ss.insert(s); } while (next_permutation(p.begin(), p.end())); res = 1LL * res * ss.size() / 2 % mod; if (ss.size() != 24) join(i, j + n / 2); } } int cnt = n / 2 + m / 2; for (int i = 0; i < n / 2 + m / 2; ++i) cnt -= find(i) == i; for (int i = 0; i < cnt; ++i) res = 2 * res % mod; cout << res; }
Submission Info
Submission Time | |
---|---|
Task | I - Reverse Grid |
User | aome |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1536 Byte |
Status | WA |
Exec Time | 79 ms |
Memory | 256 KB |
Judge Result
Set Name | sample | all | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 1900 | ||||||
Status |
|
|
Set Name | Test Cases |
---|---|
sample | sample-01.txt, sample-02.txt |
all | sample-01.txt, sample-02.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 01-11.txt, 01-12.txt, 01-13.txt, 01-14.txt, 01-15.txt, 01-16.txt, 01-17.txt, 01-18.txt, 01-19.txt, 01-20.txt, 01-21.txt, 01-22.txt, 01-23.txt, 01-24.txt, 01-25.txt, 01-26.txt, 01-27.txt, 01-28.txt, 01-29.txt, 01-30.txt, 01-31.txt, 01-32.txt, 01-33.txt, 01-34.txt, 01-35.txt, sample-01.txt, sample-02.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01-01.txt | AC | 1 ms | 256 KB |
01-02.txt | WA | 1 ms | 256 KB |
01-03.txt | AC | 1 ms | 256 KB |
01-04.txt | AC | 1 ms | 256 KB |
01-05.txt | WA | 1 ms | 256 KB |
01-06.txt | AC | 1 ms | 256 KB |
01-07.txt | AC | 1 ms | 256 KB |
01-08.txt | AC | 1 ms | 256 KB |
01-09.txt | AC | 1 ms | 256 KB |
01-10.txt | WA | 43 ms | 256 KB |
01-11.txt | WA | 50 ms | 256 KB |
01-12.txt | WA | 52 ms | 256 KB |
01-13.txt | WA | 58 ms | 256 KB |
01-14.txt | WA | 15 ms | 256 KB |
01-15.txt | WA | 17 ms | 256 KB |
01-16.txt | WA | 66 ms | 256 KB |
01-17.txt | WA | 66 ms | 256 KB |
01-18.txt | WA | 68 ms | 256 KB |
01-19.txt | WA | 59 ms | 256 KB |
01-20.txt | WA | 58 ms | 256 KB |
01-21.txt | WA | 73 ms | 256 KB |
01-22.txt | WA | 3 ms | 256 KB |
01-23.txt | WA | 32 ms | 256 KB |
01-24.txt | WA | 61 ms | 256 KB |
01-25.txt | WA | 61 ms | 256 KB |
01-26.txt | WA | 62 ms | 256 KB |
01-27.txt | WA | 4 ms | 256 KB |
01-28.txt | WA | 10 ms | 256 KB |
01-29.txt | WA | 2 ms | 256 KB |
01-30.txt | WA | 13 ms | 256 KB |
01-31.txt | WA | 79 ms | 256 KB |
01-32.txt | WA | 66 ms | 256 KB |
01-33.txt | WA | 65 ms | 256 KB |
01-34.txt | WA | 66 ms | 256 KB |
01-35.txt | WA | 66 ms | 256 KB |
sample-01.txt | AC | 1 ms | 256 KB |
sample-02.txt | AC | 1 ms | 256 KB |