結果

問題 No.345 最小チワワ問題
ユーザー prog470
提出日時 2016-09-28 00:41:36
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 736 bytes
コンパイル時間 755 ms
コンパイル使用メモリ 79,348 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-11-21 07:29:11
合計ジャッジ時間 1,777 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21 WA * 8
権限があれば一括ダウンロードができます

ソースコード

diff #

#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, sta = 0;
	bool flag;

	for (int l = 0; l < S.size(); l++) {
		if (S[l] == 'c') {
			flag = false;
			for (int m = l + 1; m < S.size() - 1; m++) {
				if (S[m] == 'c') break;
				if (S[m] == 'w' && !flag) {
					for (int r = m+1; r < S.size();  r++) {
						if (S[r] == 'w') {
							ans = max(ans, r-l+1);
							flag = true;
							break;
						}
					}
				}
			}
		}
	}

	if (ans == 0) cout << -1 << endl;
	else cout << ans << endl;

	return 0;
}
0