結果

問題 No.1954 CHECKER×CHECKER(2)
ユーザー renren_utsrenren_uts
提出日時 2022-06-16 21:54:09
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 227 ms / 1,000 ms
コード長 1,446 bytes
コンパイル時間 1,118 ms
コンパイル使用メモリ 113,632 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-16 11:21:33
合計ジャッジ時間 3,952 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 221 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 220 ms
5,376 KB
testcase_22 AC 222 ms
5,376 KB
testcase_23 AC 2 ms
5,376 KB
testcase_24 AC 186 ms
5,376 KB
testcase_25 AC 214 ms
5,376 KB
testcase_26 AC 2 ms
5,376 KB
testcase_27 AC 221 ms
5,376 KB
testcase_28 AC 197 ms
5,376 KB
testcase_29 AC 2 ms
5,376 KB
testcase_30 AC 227 ms
5,376 KB
testcase_31 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <tuple>
#include <bitset>
#include <map>
#include <queue>
#include <time.h>
#include <utility>
#include <numeric>
#include <deque>
#include <cassert>
#include <sstream>
#include <cctype>
#include <unordered_map>
#include <algorithm>
#include <chrono>
#define ll long long
#include <time.h>
#define mod % 998244353
#define rep(i,n) for(long long i = 0;i < n;i ++)
ll MAX = 5'000'000'000'000'000'000LL;
using namespace std;



int main(){
  ll h,w;
  cin >> h >> w;
  vector<string> S(h);
  rep(i,h)cin >> S[i];
  vector<vector<ll>> a(h,vector<ll>(w,1));
  rep(i,h){
    rep(j,w){
      if(S[0][0] == S[i][j])a[i][j] = 0;
    }
  }
  vector<vector<ll>> b(h,vector<ll>(w,0));
  rep(i,h){
    rep(j,w){
      ll s = 0;
      rep(k,i+1){
        rep(l,j+1){
          s += b[k][l];
        }
      }
      if(s%2!=a[i][j])b[i][j] = 1;
    }
  }
  
  
  rep(i,h-1){
    rep(j,w-1){
      if(b[i+1][j+1]==1){
        cout << "No" << endl;
        return 0;
      }
    }
  }
  ll m;
  cin >> m;
  map<vector<ll>,ll> mp;
  rep(i,m){
    ll a,b;
    cin >> a >> b;
    mp[{a,b-1}] = 1;
  }
  rep(i,h-1){
    if(b[i+1][0] == 0){
      if(mp[{1,i}] == 0){
        cout << "No" << endl;
        return 0;
      }
    }
  }
  rep(i,w-1){
    if(b[0][i+1] == 0 and mp[{2,i}] == 0){
      cout << "No" << endl;
      return 0;
    }
  }
  
  cout << "Yes" << endl;
  return 0;
}
0