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