結果
問題 | No.2837 Flip Triomino |
ユーザー |
|
提出日時 | 2024-08-23 09:26:33 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,752 bytes |
コンパイル時間 | 4,495 ms |
コンパイル使用メモリ | 239,488 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-08-23 09:26:40 |
合計ジャッジ時間 | 7,188 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 22 WA * 12 |
コンパイルメッセージ
main.cpp: In function 'int main()': main.cpp:106:19: warning: 'y' may be used uninitialized [-Wmaybe-uninitialized] 106 | S.at(x).at(y)='W'; | ~~~~~~~~~~^~~ main.cpp:88:11: note: 'y' was declared here 88 | ll x, y; | ^ main.cpp:106:13: warning: 'x' may be used uninitialized [-Wmaybe-uninitialized] 106 | S.at(x).at(y)='W'; | ~~~~^~~ main.cpp:88:8: note: 'x' was declared here 88 | ll x, y; | ^
ソースコード
#include <bits/stdc++.h> #define rep(i, p, n) for (ll i = p; i < (ll)(n); i++) #define rep2(i, p, n) for (ll i = p; i >= (ll)(n); i--) using namespace std; using ll = long long; using ld = long double; const double pi = 3.141592653589793; const long long inf = 2 * 1e9; const long long linf = 4 * 1e18; const ll mod1 = 1000000007; const ll mod2 = 998244353; template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0;} template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } //atcoder #include <atcoder/all> using namespace atcoder; using mint1 = modint1000000007; using mint2 = modint998244353; vector<pair<ll, ll>> base={{-1, 0}, {1, 0}, {0, -1}, {0, 1}}; ll N, M; bool calc(vector<string> S) { vector<vector<bool>> G(N, vector<bool>(M)); rep(i, 0, N) { rep(j, 0, M) { if (S.at(i).at(j)=='B') { G.at(i).at(j)=true; } } } rep(i, 0, N) { rep2(j, M-1, 0) { if (!G.at(i).at(j)) { continue; } if (i<N-2) { rep(k, 0, 3) { G.at(i+k).at(j)=!G.at(i+k).at(j); } } else if (j>1) { rep(k, 0, 3) { G.at(i).at(j-k)=!G.at(i).at(j-k); } } else if (i==N-2 && j==1) { G.at(i).at(j)=!G.at(i).at(j); G.at(i+1).at(j)=!G.at(i+1).at(j); G.at(i).at(j-1)=!G.at(i).at(j-1); } else if (i==N-2) { G.at(i).at(j)=!G.at(i).at(j); G.at(i+1).at(j)=!G.at(i+1).at(j); G.at(i+1).at(j+1)=!G.at(i+1).at(j+1); } } } if (!G.at(N-1).at(0) && !G.at(N-1).at(1)) { return true; } else { return false; } } int main() { cin >> N >> M; vector<string> S(N); rep(i, 0, N) { cin >> S.at(i); } ll co=0; mint2 ans=1; ll x, y; rep(i, 0, N) { rep(j, 0, M) { if (S.at(i).at(j)=='?') { co++; x=i; y=j; } } } if (co>=2) { rep(i, 0, co) { ans*=2; } ans/=4; cout << ans.val(); } else if (co==1) { S.at(x).at(y)='W'; if (calc(S)) { cout << 1; return 0; } S.at(x).at(y)='B'; if (calc(S)) { cout << 1; return 0; } cout << 0; } else { if (calc(S)) { cout << 1; } else { cout << 0; } } }