結果

問題 No.204 ゴールデン・ウィーク(2)
ユーザー femto
提出日時 2015-12-20 01:17:06
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 595 bytes
コンパイル時間 534 ms
コンパイル使用メモリ 62,912 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-24 11:49:23
合計ジャッジ時間 1,966 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 46
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

int c(string w) {
	int d = 0, ret = 0;
	for(int i = 0; i < 42; i++) {
		if(w[i] == 'o') d++;
		else d = 0;
		ret = max(ret, d);
	}
	return ret;
}

int main() {
	int d;
	string w, w1, w2;
	cin >> d >> w1 >> w2;
	w = "xxxxxxxxxxxxxx" + w1 + w2 + "xxxxxxxxxxxxxx";

	int ans = 0;
	for(int i = 0; i <= 28; i++) {
		string ww = w;
		bool flag = true;
		for(int j = 0; j < d; j++) {
			if(ww[i + j] == 'o') {
				break;
			}
			ww[i + j] = 'o';
		}
		ans = max(ans, c(ww));
	}

	cout << ans << endl;
}
0