結果
問題 | No.226 0-1パズル |
ユーザー |
|
提出日時 | 2022-12-11 09:58:53 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
CE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 1,096 bytes |
コンパイル時間 | 762 ms |
コンパイル使用メモリ | 93,360 KB |
最終ジャッジ日時 | 2024-11-15 05:28:37 |
合計ジャッジ時間 | 1,262 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.cpp: In function 'int main()': main.cpp:6:10: error: incomplete type 'std::ios' {aka 'std::basic_ios<char>'} used in nested name specifier 6 | ios::sync_with_stdio(false); | ^~~~~~~~~~~~~~~ main.cpp:7:5: error: 'cin' was not declared in this scope 7 | cin.tie(0); | ^~~ main.cpp:2:1: note: 'std::cin' is defined in header '<iostream>'; did you forget to '#include <iostream>'? 1 | #include <atcoder/all> +++ |+#include <iostream> 2 | using namespace std; main.cpp:38:5: error: 'cout' was not declared in this scope 38 | cout << ans.val() << '\n'; | ^~~~ main.cpp:38:5: note: 'std::cout' is defined in header '<iostream>'; did you forget to '#include <iostream>'?
ソースコード
#include <atcoder/all>using namespace std;using mint = atcoder::modint1000000007;int main(){ios::sync_with_stdio(false);cin.tie(0);int h, w;cin >> h >> w;vector<string> A(h);for(auto &&s:A)cin >> s;string s0(w, '?');for(int i = 0; i < w; i++)s0[i] = (i & 1) + '0';auto comp = [&](int y, int state){for(int x = 0; x < w; x++){if(A[y][x] == '?')continue;if(A[y][x] != (s0[x] ^ state))return false;}return true;};mint v = comp(0, 0) + comp(0, 1);string s1(w, '?');bool f = true;for(int y = 0; y < h; y++){for(int x = 0; x < w; x++){if(A[y][x] == '?')continue;if(s1[x] == '?'){s1[x] = A[y][x] ^ (y & 1);continue;}if(A[y][x] != (s1[x] ^ (y & 1))) f = false;}if(y) v = comp(y, 0) * v + comp(y, 1) * v;}A[0] = s1;mint ans = v;if(f)ans += mint(2).pow(count(s1.begin(), s1.end(), '?')) - comp(0, 0) - comp(0, 1);cout << ans.val() << '\n';}