結果
| 問題 |
No.345 最小チワワ問題
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-11-14 16:59:26 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 662 bytes |
| コンパイル時間 | 1,190 ms |
| コンパイル使用メモリ | 158,572 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-25 12:05:35 |
| 合計ジャッジ時間 | 2,049 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 29 |
ソースコード
#include "bits/stdc++.h"
using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a) for(int i=0;i<a;i++)
typedef long long ll;
typedef pair<int, int> PI;
typedef pair<int, PI> V;
typedef vector<int> VE;
const ll mod = 100000000000;
using namespace std;
int main() {
string s;
int cnt=0,len;
int a=101;
cin>>s;
while(s.find('c')!=-1){
cnt=0;
rep(i,s.find('c'),s.length()){
if(s[i]=='w')cnt+=1;
if(cnt==2){
len=i-s.find('c')+1;
a=min(a,len);
break;
}
}
s.replace(s.find('c'),1,"*");
}
if(a!=101){cout<<a<<endl;}
else {cout<<-1<<endl;}
}