結果

問題 No.1954 CHECKER×CHECKER(2)
ユーザー SSRSSSRS
提出日時 2022-05-20 22:14:35
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 3 ms / 1,000 ms
コード長 1,176 bytes
コンパイル時間 1,863 ms
コンパイル使用メモリ 173,860 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-20 12:57:19
合計ジャッジ時間 2,849 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 2 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 2 ms
4,348 KB
testcase_15 AC 2 ms
4,348 KB
testcase_16 AC 2 ms
4,348 KB
testcase_17 AC 2 ms
4,348 KB
testcase_18 AC 2 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 3 ms
4,348 KB
testcase_23 AC 2 ms
4,348 KB
testcase_24 AC 3 ms
4,348 KB
testcase_25 AC 3 ms
4,348 KB
testcase_26 AC 2 ms
4,348 KB
testcase_27 AC 3 ms
4,348 KB
testcase_28 AC 3 ms
4,348 KB
testcase_29 AC 2 ms
4,348 KB
testcase_30 AC 3 ms
4,348 KB
testcase_31 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main(){
  int H, W;
  cin >> H >> W;
  vector<string> S(H);
  for (int i = 0; i < H; i++){
    cin >> S[i];
  }
  int M;
  cin >> M;
  vector<int> t(M), n(M);
  for (int i = 0; i < M; i++){
    cin >> t[i] >> n[i];
    n[i]--;
  }
  bool ok = true;
  for (int i = 0; i < H - 1; i++){
    for (int j = 0; j < W - 1; j++){
      int cnt = 0;
      for (int k = 0; k < 2; k++){
        for (int l = 0; l < 2; l++){
          if (S[i + k][j + l] == '#'){
            cnt++;
          }
        }
      }
      if (cnt % 2 == 1){
        ok = false;
      }
    }
  }
  if (!ok){
    cout << "No" << endl;
  } else {
    vector<bool> h(H, false), w(W, false);
    for (int i = 0; i < M; i++){
      if (t[i] == 1){
        h[n[i]] = true;
      }
      if (t[i] == 2){
        w[n[i]] = true;
      }
    }
    for (int i = 0; i < H - 1; i++){
      if (S[i][0] == S[i + 1][0] && !h[i]){
        ok = false;
      }
    }
    for (int i = 0; i < W - 1; i++){
      if (S[0][i] == S[0][i + 1] && !w[i]){
        ok = false;
      }
    }
    if (ok){
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
}
0