Submission #7351018


Source Code Expand

// #pragma GCC target("avx2")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3121000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
}
// ここから編集しろ
int UF[510];
int FIND(int a){
	if(UF[a]<0)return a;
	return UF[a]=FIND(UF[a]);
}
void UNION(int a,int b){
	a=FIND(a);b=FIND(b);if(a==b)return;UF[a]+=UF[b];UF[b]=a;
}
char in[210][210];
char t[210];
char s[5];
int main(){
	for(int i=0;i<510;i++)UF[i]=-1;
	int a,b;scanf("%d%d",&a,&b);
	for(int i=0;i<a;i++)scanf("%s",in[i]);
	long long ret=1;
	for(int i=0;i<a/2;i++){
		for(int j=0;j<b/2;j++){
			s[0]=in[i][j];
			s[1]=in[i][b-1-j];
			s[2]=in[a-1-i][j];
			s[3]=in[a-1-i][b-1-j];
			std::sort(s,s+4);
			int cnt=0;
			do{
				cnt++;
			}while(next_permutation(s,s+4));
			if(cnt==24){
				ret=ret*12%mod;
				UNION(i,j+a/2);
			}else{
				ret=ret*cnt%mod;
			}
		}
	}
	for(int i=0;i<a/2+b/2;i++){
		if(FIND(i)!=i){
			ret=ret*2%mod;
		}
	}
	if(a%2){
		for(int i=0;i<b;i++)t[i]=in[a/2][i];
		reverse(t,t+b);
		bool ok=false;
		for(int i=0;i<b;i++)if(t[i]!=in[a/2][i])ok=true;
		if(ok)ret=ret*2%mod;
	}
	if(b%2){
		for(int i=0;i<a;i++)t[i]=in[i][b/2];
		reverse(t,t+a);
		bool ok=false;
		for(int i=0;i<a;i++)if(t[i]!=in[i][b/2])ok=true;
		if(ok)ret=ret*2%mod;
	}
	printf("%lld\n",ret);
}

Submission Info

Submission Time
Task I - Reverse Grid
User tozangezan
Language C++14 (GCC 5.4.1)
Score 1900
Code Size 2708 Byte
Status AC
Exec Time 2 ms
Memory 256 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:77:29: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  int a,b;scanf("%d%d",&a,&b);
                             ^
./Main.cpp:78:39: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  for(int i=0;i<a;i++)scanf("%s",in[i]);
                                       ^

Judge Result

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