結果
| 問題 |
No.1954 CHECKER×CHECKER(2)
|
| コンテスト | |
| ユーザー |
Nachia
|
| 提出日時 | 2022-05-20 22:32:16 |
| 言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 1,000 ms |
| コード長 | 1,334 bytes |
| コンパイル時間 | 2,944 ms |
| コンパイル使用メモリ | 119,552 KB |
| 最終ジャッジ日時 | 2025-01-29 10:59:17 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 29 |
ソースコード
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <array>
#include <atcoder/modint>
using namespace std;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
const i64 INF = 1001001001001001001;
using modint = atcoder::static_modint<998244353>;
int main(){
int H,W; cin >> H >> W;
vector<string> S(H);
rep(y,H) cin >> S[y];
auto inverse = [](char c) -> char { return '#' ^ '.' ^ c; };
if(S[0][0] == '#') rep(y,H) rep(x,W) S[y][x] = inverse(S[y][x]);
rep(y,H) rep(x,W) if((y+x)&1) S[y][x] = inverse(S[y][x]);
vector<vector<int>> A(H, vector<int> (W));
rep(y,H-1) rep(x,W-1) A[y][x] = (S[y][x]^S[y+1][x]^S[y][x+1]^S[y+1][x+1]) ? 1 : 0;
rep(y,H-1) A[y][W-1] = (S[y][W-1]^S[y+1][W-1]) ? 1 : 0;
rep(x,W-1) A[H-1][x] = (S[H-1][x]^S[H-1][x+1]) ? 1 : 0;
int M; cin >> M;
rep(i,M){
int t, n; cin >> t >> n;
if(t == 1) A[n-1][W-1] = 0;
if(t == 2) A[H-1][n-1] = 0;
}
bool ans = true;
rep(y,H) rep(x,W) if(A[y][x]) ans = false;
cout << (ans ? "Yes\n" : "No\n");
return 0;
}
struct ios_do_not_sync{
ios_do_not_sync(){
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
}
} ios_do_not_sync_instance;
Nachia