結果
| 問題 |
No.345 最小チワワ問題
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-03-01 00:47:23 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 537 bytes |
| コンパイル時間 | 556 ms |
| コンパイル使用メモリ | 56,824 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-25 11:35:25 |
| 合計ジャッジ時間 | 1,300 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 29 |
ソースコード
#include <iostream>
#include <cstring>
using namespace std;
int main() {
int cnt=0,ans=10000;
string s;
cin>>s;
for(int i=0;i<s.size();i++){
if(s[i]=='c'){
for(int j=i+1;j<s.size();j++){
if(s[j]=='w'){
cnt++;
}
if(cnt==2){
ans=min(ans,j-i+1);
}
}
cnt=0;
}
}
if(ans<1000)
cout<<ans<<endl;
else
cout<<-1<<endl;
return 0;
}