結果
問題 |
No.345 最小チワワ問題
|
ユーザー |
![]() |
提出日時 | 2016-10-07 22:06:26 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 624 bytes |
コンパイル時間 | 571 ms |
コンパイル使用メモリ | 73,228 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-09-25 11:54:02 |
合計ジャッジ時間 | 1,496 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 29 |
ソースコード
#include<iostream> #include<algorithm> #include<cstdio> #include<cstdlib> #include<vector> #include<map> #include<queue> #include<string> #include<sstream> #include<cmath> using namespace std; int main(){ string s; cin >> s; // bool fl = false; int ans = 100; for(int i=0; i<s.size(); i++){ int w = 0; int cnt = 0; if( s[i] == 'c' ){ for(int j=i; j<s.size(); j++){ if( s[j] == 'w' ) w++; cnt++; if( w == 2 ) break; } } if( ans > cnt && cnt != 0 && w == 2 ) ans = cnt; } if( ans != 100 ) cout << ans << endl; else cout << -1 << endl; return 0; }