結果
| 問題 | No.345 最小チワワ問題 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-09-26 13:43:03 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 2,000 ms |
| コード長 | 595 bytes |
| 記録 | |
| コンパイル時間 | 1,411 ms |
| コンパイル使用メモリ | 210,128 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-06-27 18:32:06 |
| 合計ジャッジ時間 | 2,526 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 29 |
ソースコード
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
int main(){
cin.tie(0);
ios::sync_with_stdio(0);
string s; cin >> s;
int ans = 1e9;
rep(i,int(s.size())) {
if(s[i] == 'c') {
int cnt = 0;
for(int j = i + 1; j < int(s.size()); j++) {
if(s[j] == 'w') cnt++;
if(cnt == 2) {
ans = min(ans, j - i + 1);
break;
}
}
}
}
cout << (ans == int(1e9) ? -1 : ans) << endl;
}