結果

問題 No.204 ゴールデン・ウィーク(2)
ユーザー Mcpu3
提出日時 2018-12-25 22:27:14
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 789 bytes
コンパイル時間 839 ms
コンパイル使用メモリ 67,616 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-10-01 13:33:48
合計ジャッジ時間 2,090 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 42 WA * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main() {
	int D, ans = 0, sum;
	string C = "xxxxxxxxxxxxxx", tmp;
	cin >> D;
	for (int i = 0; i < 2; ++i) {
		cin >> tmp;
		C += tmp;
	}
	C += "xxxxxxxxxxxxxx";
	if (D == 0) {
		sum = 0;
		for (size_t i = 0; i < 42; ++i) {
			if (tmp[i] == 'o') ++sum;
			else {
				ans = max(ans, sum);
				sum = 0;
			}
		}
	}
	else {
		for (size_t i = 0; i < 43 - D; ++i) {
			sum = 0;
			tmp = C;
			// tmp.replace(i, D, D, 'o');
			for (size_t j = i; j < D + i; ++j) {
				if (tmp[j] == 'o') break;
				tmp[j] = 'o';
			}
			for (size_t j = 0; j < 42; ++j) {
				if (tmp[j] == 'o') ++sum;
				else {
					ans = max(ans, sum);
					sum = 0;
				}
			}
		}
	}
	cout << ans;
}
0