結果

問題 No.1954 CHECKER×CHECKER(2)
ユーザー 沙耶花沙耶花
提出日時 2022-05-20 23:07:09
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 159 ms / 1,000 ms
コード長 1,422 bytes
コンパイル時間 4,462 ms
コンパイル使用メモリ 267,740 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-20 14:00:27
合計ジャッジ時間 6,229 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 1 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 3 ms
4,348 KB
testcase_14 AC 6 ms
4,348 KB
testcase_15 AC 6 ms
4,348 KB
testcase_16 AC 6 ms
4,348 KB
testcase_17 AC 2 ms
4,348 KB
testcase_18 AC 3 ms
4,348 KB
testcase_19 AC 2 ms
4,348 KB
testcase_20 AC 2 ms
4,348 KB
testcase_21 AC 3 ms
4,348 KB
testcase_22 AC 24 ms
4,348 KB
testcase_23 AC 2 ms
4,348 KB
testcase_24 AC 44 ms
4,348 KB
testcase_25 AC 37 ms
4,348 KB
testcase_26 AC 3 ms
4,348 KB
testcase_27 AC 145 ms
4,348 KB
testcase_28 AC 40 ms
4,348 KB
testcase_29 AC 3 ms
4,348 KB
testcase_30 AC 159 ms
4,348 KB
testcase_31 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using mint = modint998244353;
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf 1000000001


int main() {
    
	int h,w;
	cin>>h>>w;
	vector<string> s(h);
	rep(i,h)cin>>s[i];
	
	vector<vector<int>> n(2);
	int m = 0;
	cin>>m;
	rep(i,m){
		int t,nx;
		cin>>t>>nx;
		n[t-1].push_back(nx);
	}
	
	if(n[0].size()>n[1].size()){
		swap(n[0],n[1]);
		swap(h,w);
		
		vector<string> ss(h,string(w,'.'));
		rep(i,h){
			rep(j,w){
				ss[i][j] = s[j][i];
			}
		}
		swap(ss,s);
	}
	
	rep(i,1<<n[0].size()){
		vector<int> t(h,0);
		rep(j,n[0].size()){
			if((i>>j)&1){
				rep(k,n[0][j])t[k] ^= 1;
			}
		}
		
		auto ss = s;
		rep(j,h){
			if(t[j]==0)continue;
			rep(k,w){
				if(ss[j][k]=='.')ss[j][k]='#';
				else ss[j][k]='.';
			}
		}
		t.assign(w,0);
		rep(j,n[1].size()){
			if(n[1][j]==w)continue;
			if(s[0][n[1][j]]!=s[0][n[1][j]-1])continue;
			rep(k,n[1][j])t[k] ^= 1;
		}
		rep(j,h){
			rep(k,w){
				if(t[k]==1){
					if(ss[j][k]=='.')ss[j][k]='#';
				else ss[j][k]='.';
				}
			}
		}
		bool f = true;
		rep(j,h){
			rep(k,w){
				if(j!=h-1){
					if(ss[j][k]==ss[j+1][k]){
						f = false;
						goto L;
					}
				}
				if(k!=w-1){
					if(ss[j][k]==ss[j][k+1]){
						f = false;
						goto L;
					}
				}
			}
		}
		L:;
		if(f){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	
	cout<<"No"<<endl;
	
	
    return 0;
}
0