結果
| 問題 | No.345 最小チワワ問題 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-07-27 15:13:57 |
| 言語 | C++17 (gcc 15.3.0 + boost 1.92.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 1 ms / 2,000 ms |
| + 400µs | |
| コード長 | 416 bytes |
| 記録 | |
| コンパイル時間 | 1,894 ms |
| コンパイル使用メモリ | 210,120 KB |
| 実行使用メモリ | 9,900 KB |
| 最終ジャッジ日時 | 2026-10-10 22:13:46 |
| 合計ジャッジ時間 | 2,724 ms |
|
ジャッジサーバーID (参考情報) |
judge4_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 31 |
ソースコード
#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;
}