結果
| 問題 |
No.345 最小チワワ問題
|
| コンテスト | |
| ユーザー |
chiyoda
|
| 提出日時 | 2016-06-21 18:34:08 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 444 bytes |
| コンパイル時間 | 468 ms |
| コンパイル使用メモリ | 57,676 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-10-11 18:30:25 |
| 合計ジャッジ時間 | 1,398 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 WA * 1 |
| other | AC * 22 WA * 7 |
ソースコード
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
string s;
cin >> s;
int n = s.size();
int w1 = n;
int w2 = n;
int res = n + 1;
for (int i = n - 1; i >= 0; i--) {
if (s[i] == 'w') {
w2 = w1;
w1 = i;
} else if (s[i] == 'c'){
if (w1 != n) {
res = min(res, w2 - i + 1);
}
}
}
if (res == n + 1) res = -1;
cout << res << endl;
return 0;
}
chiyoda