結果
| 問題 | No.345 最小チワワ問題 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-03-01 01:17:47 |
| 言語 | C++11(廃止可能性あり) (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 630 bytes |
| 記録 | |
| コンパイル時間 | 617 ms |
| コンパイル使用メモリ | 56,004 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-24 12:57:58 |
| 合計ジャッジ時間 | 1,417 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 WA * 1 |
| other | AC * 22 WA * 7 |
ソースコード
//============================================================================
// Name : yukicoder.cpp
// Author : albicilla
// Version :
// Copyright : albicilla
// Description : Hello World in C++, Ansi-style
//============================================================================
#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'&&w2!=S){
ans=min(ans,w1-i+1);
}
}
if(ans==100)cout<<-1<<endl;
else cout<<ans<<endl;
return 0;
}