結果
問題 | No.345 最小チワワ問題 |
ユーザー |
![]() |
提出日時 | 2017-02-07 23:54:20 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 461 bytes |
コンパイル時間 | 1,970 ms |
コンパイル使用メモリ | 158,620 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-25 11:56:18 |
合計ジャッジ時間 | 2,328 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 29 |
ソースコード
#include <bits/stdc++.h>using namespace std;int main(void) {string s;cin >> s;bool flag = 0;int count = 0;int now,ans=5000000,tmp=-1;int j=0;for (int i = 0; i < s.length(); ++i) {count=0;if (s[i] == 'c') {now=i;j=i;while (j < s.length()) {j++;if(s[j]=='w'&&count==0){count++;}else if(s[j]=='w'&&count==1){tmp=j-now+1;ans=min(ans,tmp);}}}}cout<<((ans!=5000000)?ans:-1)<<endl;}