結果
問題 | No.345 最小チワワ問題 |
ユーザー | KKT89 |
提出日時 | 2019-07-02 03:46:53 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 421 bytes |
コンパイル時間 | 538 ms |
コンパイル使用メモリ | 70,796 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-18 14:58:36 |
合計ジャッジ時間 | 1,355 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 29 |
ソースコード
#include <iostream> #include <algorithm> #include <vector> #include <string> using namespace std; typedef long long int ll; int main(){ int ans=101; string s; cin >>s; for(int i=0;i<s.size();i++){ bool a=true; bool b=true; for(int j=i;j<s.size();j++){ if(s[j]=='c')a=false; if(!a&&!b&&s[j]=='w'){ ans=min(ans,j-i+1); } if(!a&&s[j]=='w')b=false; } } if(ans>100)ans=-1; cout << ans << endl; }