結果
問題 |
No.2283 Prohibit Three Consecutive
|
ユーザー |
|
提出日時 | 2023-04-29 00:54:45 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,658 bytes |
コンパイル時間 | 253 ms |
コンパイル使用メモリ | 28,160 KB |
最終ジャッジ日時 | 2025-02-12 15:50:10 |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 8 WA * 5 |
コンパイルメッセージ
main.cpp: In function ‘int main(int, const char**)’: main.cpp:78:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 78 | scanf("%d", &T); | ~~~~~^~~~~~~~~~ main.cpp: In function ‘void Solution()’: main.cpp:66:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 66 | scanf("%d", &n); | ~~~~~^~~~~~~~~~ main.cpp:68:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 68 | scanf("%s", a); | ~~~~~^~~~~~~~~
ソースコード
// Problem: No.2283 Prohibit Three Consecutive // Contest: yukicoder // URL: https://yukicoder.me/problems/no/2283 // Memory Limit: 512 MB // Time Limit: 2000 ms // // Powered by CP Editor (https://cpeditor.org) // #include <bits/stdc++.h> #include <cstdio> // #include <iostream> // #include <cstring> // #include <algorithm> // #include <cmath> // #include <queue> // #include <map> // #include <vector> // #include <stack> // #include <set> // #include <unordered_map> // #include <cstdlib> // typedef long long ll; using namespace std; const int inf = 0x3f3f3f3f, N = 1e5 + 10; // const ll INF = __LONG_LONG_MAX__; int n; bool dfs(char *s, int idx) { if (idx == n) return true; if (s[idx] != '?') { if (idx >= 2) { if (s[idx] == s[idx - 1] && s[idx] == s[idx - 2]) return false; } else if (idx == 1) { if (s[idx] == s[idx - 1] && s[idx] == s[n - 1]) { return false; } } else { if (s[idx] == s[n - 1] && s[idx] == s[n - 2]) { return false; } } return dfs(s, idx + 1); } s[idx] = '1'; if (dfs(s, idx)) return true; s[idx] = '0'; if (dfs(s, idx)) return true; return false; } inline void Solution() { scanf("%d", &n); char a[n + 10]; scanf("%s", a); if (dfs(a, 0)) printf("Yes\n"); else printf("No\n"); } int main(int argc, char const *argv[]) { int T = 1; scanf("%d", &T); while (T--) { Solution(); } return 0; }