結果
| 問題 |
No.345 最小チワワ問題
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-06-10 22:36:23 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 426 bytes |
| コンパイル時間 | 1,605 ms |
| コンパイル使用メモリ | 167,888 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-23 18:33:23 |
| 合計ジャッジ時間 | 3,217 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 29 |
ソースコード
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
typedef long long ll;
int main(){
string s; cin>>s;
int n=s.size();
int ans=1000;
for(int i=0; i<n; i++){
if(s[i]=='c'){
for(int j=i+1; j<n; j++){
if(s[j]=='w'){
for(int k=j+1; k<n; k++){
if(s[k]=='w') ans=min(ans, k-i+1);
}
}
}
}
}
if(ans<1000) cout << ans << endl;
else cout << "-1" << endl;
}