結果

問題 No.1566 All Even
ユーザー 👑 Nachia
提出日時 2021-06-26 13:26:56
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,734 bytes
コンパイル時間 615 ms
コンパイル使用メモリ 72,328 KB
最終ジャッジ日時 2025-01-22 13:14:27
ジャッジサーバーID
(参考情報)
judge5 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 14 WA * 14
権限があれば一括ダウンロードができます

ソースコード

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;
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0