結果

問題 No.226 0-1パズル
ユーザー btkbtk
提出日時 2015-06-15 10:47:59
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 965 bytes
コンパイル時間 473 ms
コンパイル使用メモリ 54,816 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-21 02:07:15
合計ジャッジ時間 1,888 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 WA -
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<string>

using namespace std;
typedef long long LL;
const LL mod=(LL)1e9+7;
bool ch[100][100][2];
bool ic[100][2];
string ms[100];
#define re(q,w) for(int (q)=0;(q)<(w);(q)++)
int H,W;
int checkICHIMATSU(){
	LL res=1;
	re(i,H)
		re(bb,2){
			int b=bb;
			bool f;
			f=true;
			re(j,W-1){
				f&=(ch[i][j][b]&&ch[i][j+1][1-b]);
				b=1-b;
			}
			ic[i][bb]=f;
		}
	re(i,H){
		int cnt=0;
		re(b,2)if(ic[i][b])cnt++;
		res=(res*cnt)%mod;
	}

	re(bb,2){
		int b=bb;
		bool f=true;
		re(i,H-1){
			f&=(ic[i][b]&&ic[i+1][1-b]);
			b=1-b;
		}
		if(f)res--;
	}
	if(res<0)res+=mod;
	return res;
}
int main(){
	cin>>H>>W;
	re(i,H)cin>>ms[i];
	re(i,H)for(int j=0;j<W;j++)ch[i][j][0]=(ms[i][j]!='1'),ch[i][j][1]=(ms[i][j]!='0');
	LL x=checkICHIMATSU();
	re(j,W)for(int i=H-2;i>=0;i--)re(b,2)ch[i][j][b]&=ch[i+1][j][1-b];
	LL res=1;
	re(i,H){
		int cnt=0;
		re(b,2)if(ch[0][i][b])cnt++;
		res=(res*cnt)%mod;
	}
	cout<<(res+x)%mod<<endl;
	return 0;
}
0