結果
| 問題 |
No.345 最小チワワ問題
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-09-26 13:43:03 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 595 bytes |
| コンパイル時間 | 2,044 ms |
| コンパイル使用メモリ | 192,952 KB |
| 最終ジャッジ日時 | 2025-02-07 16:01:08 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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;
}