結果
| 問題 |
No.345 最小チワワ問題
|
| コンテスト | |
| ユーザー |
a01sa01to
|
| 提出日時 | 2023-12-09 00:51:35 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 2,000 ms |
| コード長 | 589 bytes |
| コンパイル時間 | 2,205 ms |
| コンパイル使用メモリ | 192,996 KB |
| 最終ジャッジ日時 | 2025-02-18 09:43:22 |
|
ジャッジサーバーID (参考情報) |
judge5 / 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;
}
a01sa01to