結果
問題 |
No.345 最小チワワ問題
|
ユーザー |
![]() |
提出日時 | 2016-03-04 10:19:51 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 459 bytes |
コンパイル時間 | 603 ms |
コンパイル使用メモリ | 64,744 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-25 11:36:32 |
合計ジャッジ時間 | 1,559 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 29 |
ソースコード
#include <iostream> #include <string> #include <queue> using namespace std; int main() { ios::sync_with_stdio(false); string s; queue<int> q; cin >> s; int ret = 101; for( int i = s.size()-1; i>=0; i-- ){ if( s[i] == 'w' ){ q.push( i ); if( q.size() > 2 ) q.pop(); } if( s[i] == 'c' && q.size() == 2 ){ ret = min( ret, q.front() - i + 1 ); } } if( ret > 100 ) cout << -1 << endl; else cout << ret << endl; }