結果
問題 |
No.345 最小チワワ問題
|
ユーザー |
![]() |
提出日時 | 2016-02-26 23:03:55 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 592 bytes |
コンパイル時間 | 527 ms |
コンパイル使用メモリ | 57,880 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-09-22 22:40:29 |
合計ジャッジ時間 | 4,759 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 RE * 2 |
other | AC * 8 RE * 21 |
ソースコード
#include <iostream> #include <list> using namespace std; int main(void){ string s; cin >> s; int min = -1; list<int*> c; for(int i = 0; i < s.length(); i++){ if(s[i] == 'c'){ int *ci = new int[2]; ci[0] = i; ci[1] = 0; c.push_back(ci); }else if(s[i] == 'w'){ list<int*>::iterator it = c.begin(); while( it != c.end() ){ int *ci = *it; if(++ci[1] >= 2){ min = i - ci[0] + 1 < min || min < 0 ? i - ci[0] + 1 : min; c.pop_front(); } ++it; } } } cout << min << endl; return 0; }