結果
問題 | No.345 最小チワワ問題 |
ユーザー |
![]() |
提出日時 | 2016-03-12 22:11:20 |
言語 | C++11 (gcc 13.3.0) |
結果 |
TLE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 519 bytes |
コンパイル時間 | 1,310 ms |
コンパイル使用メモリ | 160,304 KB |
実行使用メモリ | 10,016 KB |
最終ジャッジ日時 | 2024-11-15 22:59:01 |
合計ジャッジ時間 | 5,326 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 28 TLE * 1 |
ソースコード
#include <bits/stdc++.h>using namespace std;int main() {string str;cin >> str;const int inf = 1 << 28;int ans = inf;for (int i = 0; i < str.size() - 2; i++) {int j = i;while (j < str.size() && str[j] != 'c')j++; j++;while (j < str.size() && str[j] != 'w')j++; j++;while (j < str.size() && str[j] != 'w')j++;if (j < str.size()) ans = min(ans, j - i + 1);}if (ans < inf) cout << ans << endl;else cout << -1 << endl;return 0;}