結果

問題 No.1566 All Even
ユーザー 👑 NachiaNachia
提出日時 2021-06-26 13:26:56
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,734 bytes
コンパイル時間 562 ms
コンパイル使用メモリ 73,304 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-07 16:29:04
合計ジャッジ時間 1,715 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i,n) for(int i=0; i<(n); i++)



int N,M;
int X[3][3] = {};

int popcount(int x){
  int res = 0;
  rep(i,9) res += (x>>i) & 1;
  return res;
}

int main(){
  cin >> N >> M;
  rep(i,3) rep(j,3) X[i][j] = 0;
  rep(i,M){
    int a,b,c; cin >> a >> b >> c; a--; b--;
    X[a%3][b%3] |= (1<<(1-c));
  }
  for(int i=2; i<min(5,N); i++) for(int j=2; j<min(5,N); j++) X[i][j] |= 1;

  int ans = 0;
  if(N == 2){
    rep(i,1<<4){
      int D[2][2];
      rep(x,2) rep(y,2) D[x][y] = (i >> (x+y*2)) & 1;
      bool ok = true;
      rep(x,2) rep(y,2) if(X[x][y] & (1 << D[x][y])) ok = false;
      if(popcount(i) % 2 == 1) ok = false;
      if(ok) ans++;
    }
  }
  else{
    rep(i,1<<9){
      int D[3][3];
      rep(x,3) rep(y,3) D[x][y] = (i >> (x+y*3)) & 1;
      bool ok = true;
      rep(x,3) rep(y,3) if(X[x][y] & (1 << D[x][y])) ok = false;
      if(popcount(i) % 2 != 1) ok = false;
      if(popcount(i & 0b000'011'011) % 2 != 0) ok = false;
      if(popcount(i & 0b000'110'110) % 2 != 0) ok = false;
      if(popcount(i & 0b000'111'111) % 2 != 0) ok = false;
      if(popcount(i & 0b011'011'000) % 2 != 0) ok = false;
      if(popcount(i & 0b110'110'000) % 2 != 0) ok = false;
      if(popcount(i & 0b111'111'000) % 2 != 0) ok = false;
      if(popcount(i & 0b011'000'011) % 2 != 0) ok = false;
      if(popcount(i & 0b110'000'110) % 2 != 0) ok = false;
      if(popcount(i & 0b111'000'111) % 2 != 0) ok = false;
      if(ok) ans++;
    }
  }
  cout << ans << "\n";
  return 0;
}

struct ios_do_not_sync{
  ios_do_not_sync(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
  }
} ios_do_not_sync_inst;
0