結果
問題 | No.345 最小チワワ問題 |
ユーザー | a01sa01to |
提出日時 | 2023-12-09 00:51:35 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 589 bytes |
コンパイル時間 | 2,129 ms |
コンパイル使用メモリ | 200,940 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-27 03:21:32 |
合計ジャッジ時間 | 3,210 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 29 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; for (int ans = 1; ans <= s.size(); ans++) { bool ok = false; for (int i = 0; i + ans - 1 < s.size(); i++) { string t = s.substr(i, ans); bool c1 = false, c2 = false, c3 = false; for (int j = 0; j < t.size(); j++) { if (!c1 && t[j] == 'c') c1 = true; else if (t[j] == 'w') { if (!c1) continue; else if (!c2) c2 = true; else if (!c3) c3 = true; } } if (c1 && c2 && c3) ok = true; } if (ok) { cout << ans << endl; return 0; } } cout << -1 << endl; }