Submission #994627


Source Code Expand

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define P 1000000007

#define N 210
int n, m;
string a[N];

int ff(string a, string b, string c, string d) {
	multiset<string> u;
	u.insert(a);
	u.insert(b);
	u.insert(c);
	u.insert(d);
	a = *u.begin();
	u.erase(u.begin());
	b = *u.begin();
	u.erase(u.begin());
	c = *u.begin();
	u.erase(u.begin());
	d = *u.begin();
	u.erase(u.begin());
	if (a == b && b == c && c == d) return 1;
	if (a == b && b == c || b == c && c == d) return 4;
	if (a == b && c == d) return 6;
	if (a == b || b == c || c == d) return 12;
	return 12;
}

bool gg(string a, string b, string c, string d) {
	multiset<string> u;
	u.insert(a);
	u.insert(b);
	u.insert(c);
	u.insert(d);
	a = *u.begin();
	u.erase(u.begin());
	b = *u.begin();
	u.erase(u.begin());
	c = *u.begin();
	u.erase(u.begin());
	d = *u.begin();
	u.erase(u.begin());
	if (a != b && b != c && c != d) return true;
	return false;
}

bool b[N], c[N];

int main() {
	cin >> n >> m;
	for (int i = 0; i < n; i ++) {
		cin >> a[i];
	}
	ll S = 1;
	for (int i = 0; i*2 < n-1; i ++)
		for (int j = 0; j*2 < m-1; j ++) {
			S = (ll)S*ff(string(1, a[i][j]), string(1, a[n-1-i][j]), string(1, a[n-1-i][m-1-j]), string(1, a[i][m-1-j]))%P;
			if (gg(string(1, a[i][j]), string(1, a[n-1-i][j]), string(1, a[n-1-i][m-1-j]), string(1, a[i][m-1-j]))) b[i] = c[j] = true;
		}
	/*
	for (int i = 0; i*2 < n-1; i ++) {
		int j = 0;
		S = (ll)S*gg(string(1, a[i][j]), string(1, a[n-1-i][j]), string(1, a[n-1-i][m-1-j]), string(1, a[i][m-1-j]))%P;
	}
	for (int j = 1; j*2 < m-1; j ++) {
		int i = 0;
		S = (ll)S*gg(string(1, a[i][j]), string(1, a[n-1-i][j]), string(1, a[n-1-i][m-1-j]), string(1, a[i][m-1-j]))%P;
	}
	*/
	int T = 0;
	for (int i = 0; i*2 < n-1; i ++) if (b[i]) T ++;
	for (int j = 0; j*2 < m-1; j ++) if (c[j]) T ++;
	for (int i = 0; i < T-1; i++) S = (ll)S*2%P;
	if (n&1) {
		bool F = true;
		for (int i = 0; i < m; i++)
			if (a[n/2][i] != a[n/2][m-1-i]) F = false;
		if (!F) S = (ll)S*2%P;
	}
	if (m&1) {
		bool F = true;
		for (int i = 0; i < n; i++)
			if (a[i][m/2] != a[n-1-i][m/2]) F = false;
		if (!F) S = (ll)S*2%P;
	}
	cout << S << endl;
	return 0;
}

Submission Info

Submission Time
Task I - Reverse Grid
User sevenkplus
Language C++14 (GCC 5.4.1)
Score 1900
Code Size 2336 Byte
Status AC
Exec Time 16 ms
Memory 384 KB

Judge Result

Set Name sample all
Score / Max Score 0 / 0 1900 / 1900
Status
AC × 2
AC × 37
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
Case Name Status Exec Time Memory
01-01.txt AC 3 ms 384 KB
01-02.txt AC 3 ms 256 KB
01-03.txt AC 3 ms 256 KB
01-04.txt AC 3 ms 256 KB
01-05.txt AC 3 ms 256 KB
01-06.txt AC 3 ms 256 KB
01-07.txt AC 3 ms 256 KB
01-08.txt AC 3 ms 256 KB
01-09.txt AC 3 ms 256 KB
01-10.txt AC 14 ms 256 KB
01-11.txt AC 14 ms 256 KB
01-12.txt AC 15 ms 256 KB
01-13.txt AC 14 ms 256 KB
01-14.txt AC 6 ms 256 KB
01-15.txt AC 6 ms 256 KB
01-16.txt AC 16 ms 256 KB
01-17.txt AC 15 ms 256 KB
01-18.txt AC 16 ms 256 KB
01-19.txt AC 16 ms 256 KB
01-20.txt AC 16 ms 256 KB
01-21.txt AC 16 ms 256 KB
01-22.txt AC 3 ms 256 KB
01-23.txt AC 9 ms 256 KB
01-24.txt AC 15 ms 256 KB
01-25.txt AC 15 ms 256 KB
01-26.txt AC 16 ms 256 KB
01-27.txt AC 3 ms 256 KB
01-28.txt AC 5 ms 256 KB
01-29.txt AC 3 ms 256 KB
01-30.txt AC 5 ms 256 KB
01-31.txt AC 15 ms 256 KB
01-32.txt AC 15 ms 256 KB
01-33.txt AC 15 ms 256 KB
01-34.txt AC 16 ms 256 KB
01-35.txt AC 15 ms 256 KB
sample-01.txt AC 3 ms 256 KB
sample-02.txt AC 3 ms 256 KB