結果
| 問題 |
No.345 最小チワワ問題
|
| コンテスト | |
| ユーザー |
yuma220284
|
| 提出日時 | 2019-04-03 21:11:52 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 442 bytes |
| コンパイル時間 | 1,080 ms |
| コンパイル使用メモリ | 158,292 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-01 05:16:19 |
| 合計ジャッジ時間 | 1,866 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 29 |
ソースコード
#include "bits/stdc++.h"
using namespace std;
int main() {
string S;
cin >> S;
int bC = -1, ans = 1000;
bool C = false, W = false;
for (int i = 0; i < S.size(); i++) {
if (!C && S[i] == 'c') {
bC = i;
C = true;
}
if (C && !W && S[i] == 'w') {
W = true;
}
else if (C && W && S[i] == 'w') {
ans = min(ans, i - bC + 1);
i = bC;
C = false;
W = false;
}
}
if (ans == 1000) ans = -1;
cout << ans << endl;
}
yuma220284