結果
| 問題 |
No.345 最小チワワ問題
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-07-27 15:13:57 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 416 bytes |
| コンパイル時間 | 1,804 ms |
| コンパイル使用メモリ | 193,276 KB |
| 最終ジャッジ日時 | 2025-01-07 09:37:59 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 29 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
string s;
cin>>s;
int ans = 1e9;
int c, cw;
c=cw=-1;
for (int i = 0; i < s.size(); i++) {
if (s[i] == 'c') c = i;
else if (s[i] == 'w') {
if (cw != -1) ans = min(ans, i-cw+1);
cw = c;
}
}
if (ans == 1e9) ans = -1;
cout << ans << endl;
return 0;
}