Submission #5862982
Source Code Expand
#include<bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; const int MN = 222; int N, M; char G[MN][MN]; int chk[MN][MN]; vector<int> R, C; int main() { scanf("%d %d", &N, &M); for(int i = 0; i < N; i++) { scanf("\n"); for(int j = 0; j < M; j++) { scanf("%c", &G[i][j]); } } int ans = 1; if(N % 2) { int found = 0; for(int i = 0; i < M / 2; i++) if(G[N / 2][i] != G[N / 2][M - 1 - i]) { found = 1; break; } if(found) ans = 1LL * ans * 2 % mod; } if(M % 2) { int found = 0; for(int i = 0; i < N / 2; i++) if(G[i][M / 2] != G[N - 1 - i][M / 2]) { found = 1; break; } if(found) ans = 1LL * ans * 2 % mod; } for(int i = 0; i < N / 2; i++) { for(int j = 0; j < M / 2; j++) { vector<char> X; unordered_map<char, int> dx; X.push_back(G[i][j]); X.push_back(G[N - 1 - i][j]); X.push_back(G[i][M - 1 - j]); X.push_back(G[N - 1 - i][M - 1 - j]); sort(X.begin(), X.end()); X.resize(unique(X.begin(), X.end()) - X.begin()); for(int i = 0; i < X.size(); i++) dx[X[i]] = i; vector<int> cnt(4, 0); for(int a = 0; a < 2; a++) for(int b = 0; b < 2; b++) cnt[ dx[ G[ a? i : N - 1 - i ][ b? j : M - 1 - j ] ] ]++; if(X.size() == 4) { R.push_back(i); C.push_back(j); ans = 1LL * ans * 12 % mod; } else { int tmp = 24; for(int a = 0; a < 4; a++) for(int b = 1; b <= cnt[a]; b++) tmp /= b; ans = 1LL * ans * tmp % mod; } } } sort(R.begin(), R.end()); sort(C.begin(), C.end()); R.resize(unique(R.begin(), R.end()) - R.begin()); C.resize(unique(C.begin(), C.end()) - C.begin()); for(int i = 0; i < (int)R.size() + (int)C.size() - 1; i++) ans = 1LL * ans * 2 % mod; cout << ans; }
Submission Info
Submission Time | |
---|---|
Task | I - Reverse Grid |
User | choikiwon |
Language | C++14 (GCC 5.4.1) |
Score | 1900 |
Code Size | 2155 Byte |
Status | AC |
Exec Time | 9 ms |
Memory | 512 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:13:27: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d %d", &N, &M); ^ ./Main.cpp:16:20: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("\n"); ^ ./Main.cpp:18:34: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%c", &G[i][j]); ^
Judge Result
Set Name | sample | all | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 1900 / 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 | AC | 2 ms | 384 KB |
01-03.txt | AC | 1 ms | 256 KB |
01-04.txt | AC | 1 ms | 256 KB |
01-05.txt | AC | 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 | AC | 6 ms | 256 KB |
01-11.txt | AC | 7 ms | 256 KB |
01-12.txt | AC | 7 ms | 256 KB |
01-13.txt | AC | 6 ms | 256 KB |
01-14.txt | AC | 3 ms | 256 KB |
01-15.txt | AC | 3 ms | 256 KB |
01-16.txt | AC | 9 ms | 384 KB |
01-17.txt | AC | 9 ms | 384 KB |
01-18.txt | AC | 9 ms | 384 KB |
01-19.txt | AC | 8 ms | 256 KB |
01-20.txt | AC | 8 ms | 256 KB |
01-21.txt | AC | 8 ms | 256 KB |
01-22.txt | AC | 1 ms | 256 KB |
01-23.txt | AC | 5 ms | 384 KB |
01-24.txt | AC | 9 ms | 384 KB |
01-25.txt | AC | 8 ms | 384 KB |
01-26.txt | AC | 8 ms | 384 KB |
01-27.txt | AC | 2 ms | 256 KB |
01-28.txt | AC | 2 ms | 256 KB |
01-29.txt | AC | 1 ms | 256 KB |
01-30.txt | AC | 3 ms | 256 KB |
01-31.txt | AC | 9 ms | 512 KB |
01-32.txt | AC | 9 ms | 512 KB |
01-33.txt | AC | 9 ms | 512 KB |
01-34.txt | AC | 9 ms | 512 KB |
01-35.txt | AC | 9 ms | 512 KB |
sample-01.txt | AC | 1 ms | 256 KB |
sample-02.txt | AC | 1 ms | 256 KB |