結果
| 問題 | No.226 0-1パズル |
| コンテスト | |
| ユーザー |
chocorusk
|
| 提出日時 | 2019-01-21 18:47:54 |
| 言語 | C++11 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 1,609 bytes |
| 記録 | |
| コンパイル時間 | 733 ms |
| コンパイル使用メモリ | 126,140 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-04-03 17:13:44 |
| 合計ジャッジ時間 | 1,513 ms |
|
ジャッジサーバーID (参考情報) |
judge4_0 / judge5_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 22 |
コンパイルメッセージ
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/string:53,
from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/locale_classes.h:42,
from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/ios_base.h:43,
from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/ios:46,
from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/ostream.h:43,
from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/ostream:42,
from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/iostream:43,
from main.cpp:3:
In function 'void std::__fill_a1(_ForwardIterator, _ForwardIterator, const _Tp&) [with _ForwardIterator = int*; _Tp = int]',
inlined from 'void std::__fill_a(_FIte, _FIte, const _Tp&) [with _FIte = int*; _Tp = int]' at /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/stl_algobase.h:979:21,
inlined from 'void std::fill(_ForwardIterator, _ForwardIterator, const _Tp&) [with _ForwardIterator = int*; _Tp = int]' at /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/stl_algobase.h:1011:20,
inlined from 'int main()' at main.cpp:49:6:
/home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/stl_algobase.h:925:18: warning: 'void* __builtin_memset(void*, int, long unsigned int)' specified bound between 18446744065119617024 and 18446744073709551612 exceeds maximum object size 9223372036854775807 [-Wstringop-overflow=]
925 | *__first = __val;
| ~~~~~~~~~^~~~~~~
ソースコード
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD=1e9+7;
int h, w;
string s[100];
int main()
{
cin>>h>>w;
for(int i=0; i<h; i++) cin>>s[i];
ll ans1=1, ans2=1;
int a[100];
fill(a, a+w, -1);
bool nuee=0;
for(int i=0; i<h; i++){
for(int j=0; j<w; j++){
if(s[i][j]!='?'){
int a1=(int)(s[i][j]-'0')^(i&1);
if(a[j]>=0 && a[j]!=a1){
nuee=1;
ans1=0;
break;
}
a[j]=a1;
}
}
if(nuee) break;
}
if(!nuee){
for(int j=0; j<w; j++) if(a[j]==-1) ans1=ans1*2%MOD;
}
fill(a, a+h, -1); nuee=0;
for(int i=0; i<h; i++){
for(int j=0; j<w; j++){
if(s[i][j]!='?'){
int a1=(int)(s[i][j]-'0')^(j&1);
if(a[i]>=0 && a[i]!=a1){
nuee=1;
ans2=0;
break;
}
a[i]=a1;
}
}
if(nuee) break;
}
if(!nuee){
for(int i=0; i<h; i++) if(a[i]==-1) ans2=ans2*2%MOD;
}
ll ans3=0;
nuee=0;
for(int i=0; i<h; i++){
for(int j=0; j<w; j++){
if(s[i][j]!='?' && (s[i][j]-'0')!=((i+j)&1)){
nuee=1;
break;
}
}
if(nuee) break;
}
if(!nuee) ans3++;
nuee=0;
for(int i=0; i<h; i++){
for(int j=0; j<w; j++){
if(s[i][j]!='?' && (s[i][j]-'0')!=(((i+j)&1)^1)){
nuee=1;
break;
}
}
if(nuee) break;
}
if(!nuee) ans3++;
cout<<(ans1+ans2-ans3+MOD)%MOD<<endl;
return 0;
}
chocorusk