結果

問題 No.204 ゴールデン・ウィーク(2)
ユーザー data9824
提出日時 2015-05-22 00:48:02
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 1,019 bytes
コンパイル時間 1,892 ms
コンパイル使用メモリ 59,840 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-24 11:46:04
合計ジャッジ時間 4,909 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 46
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main() {
	int d;
	cin >> d;
	string c1, c8, c;
	cin >> c1 >> c8;
	c = string("xxxxxxx") + "xxxxxxx" + c1 + c8 + "xxxxxxx" + "xxxxxxx";
	unsigned long long weekday = 0x0;
	for (size_t i = 0; i < c.size(); ++i) {
		weekday <<= 1;
		weekday |= (c[i] == 'x');
	}
	int maxContinuousHolidays = 0;
	for (; d >= 0; --d) {
		unsigned long long paid = (1 << d) - 1;
		for (size_t i = 0; i <= c.size() - d; ++i, paid <<= 1) {
			if ((weekday | paid) == weekday) {
				unsigned long long newWeekday = weekday & ~paid;
				int continuousHolidays = 0;
				for (size_t k = 0; k < c.size(); ++k, newWeekday >>= 1) {
					if (newWeekday & 0x1) {
						maxContinuousHolidays = max(maxContinuousHolidays, continuousHolidays);
						continuousHolidays = 0;
					} else {
						++continuousHolidays;
					}
				}
				maxContinuousHolidays = max(maxContinuousHolidays, continuousHolidays);
			}
		}
	}
	cout << maxContinuousHolidays << endl;
	return 0;
}
0