結果
| 問題 |
No.345 最小チワワ問題
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-05-15 21:49:29 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 749 bytes |
| コンパイル時間 | 1,962 ms |
| コンパイル使用メモリ | 159,168 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-25 12:14:12 |
| 合計ジャッジ時間 | 2,309 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 29 |
ソースコード
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define SSTR( x ) static_cast< std::ostringstream & >( \
( std::ostringstream() << std::dec << x ) ).str()
#define ALL(s) (s).begin(), (s).end()
using namespace std;
typedef long long unsigned int llu;
typedef long long ll;
int main (){
string S;
while (cin >> S){
int w0 = -1;
int w1 = -1;
int ans = INT_MAX;
bool b = false;
REP(i,S.size()){
if(S[i] == 'c'){
w0 = i;
}
if(S[i] == 'w'){
if(w0 == -1) continue;
if(w1 != -1){
ans = min(ans, i - w1 + 1);
b = true;
}
w1 = w0;
}
}
if(b) cout << ans << endl;
else cout << -1 << endl;
}
return 0;
}