結果
問題 |
No.345 最小チワワ問題
|
ユーザー |
![]() |
提出日時 | 2016-09-27 18:42:41 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 792 bytes |
コンパイル時間 | 735 ms |
コンパイル使用メモリ | 79,220 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-11-21 07:19:36 |
合計ジャッジ時間 | 1,843 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 13 WA * 16 |
ソースコード
#include<stdio.h> #include <vector> #include <list> #include <map> #include <set> #include <queue> #include <stack> #include <algorithm> #include <sstream> #include <iostream> #include <string> #include <stdio.h> using namespace std; int main() { string S; cin >> S; int ans = 0, cnt = 0, sta = 0; for (int i = 0; i < S.size(); i++) { //cout << "i: " << i << " cnt: " << cnt <<" sta: "<<sta<< endl; if (sta == 1 || sta == 2) cnt++; if (sta == 0 && S[i] == 'c') { sta = 1; }else if (sta == 1 && S[i] == 'w') { sta = 2; }else if (sta == 2 && S[i] == 'w') { sta = 0; ans = max(ans, cnt + 1); cnt = 0; }else if ((sta == 1 || sta == 2) && S[i] == 'c') { sta = 0; cnt = 0; } } if (ans == 0) cout << -1 << endl; else cout << ans << endl; return 0; }