結果

問題 No.678 2Dシューティングゲームの必殺ビーム
ユーザー pirozhkipirozhki
提出日時 2018-06-02 19:48:54
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,104 bytes
コンパイル時間 800 ms
コンパイル使用メモリ 80,268 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-12 21:35:09
合計ジャッジ時間 1,622 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <fstream>
#include <algorithm>
#include <bitset>
#include <vector>

using namespace std;

const int NX = 1280;
const int NY = 1680;

typedef bitset<NX+1> Seq;

struct Enemy {
	int i;
	int y;
	bool h;
	Seq s;
};

Seq MakeSeq(int xl, int xr) {
	Seq s;
	for (int i = xl; i <= xr; i++) {
		s |= Seq(1) << i;
	}
	return s;
}

int main() {
	int n, xl, xr;
	cin >> n >> xl >> xr;

	Seq b = MakeSeq(xl, xr);
	
	vector<Enemy> es;
	for (int i = 0; i < n; i++) {
		int y, foo;
		cin >> xl >> foo >> xr >> y;

		xl = xl < 1 ? 1 : xl;
		xl = xl > NX ? NX : xl;
		xr = xr < 1 ? 1 : xr;
		xr = xr > NX ? NX : xr;
		y = y < 1 ? 1 : y;
		y = y > NY ? NY : y;

		Enemy e;
		e.i = i;
		e.y = y;
		e.h = false;
		e.s = MakeSeq(xl, xr);
		es.emplace_back(e);
	}

	sort(es.begin(), es.end(), [](const Enemy& a, const Enemy& b) { return a.y > b.y; });

	for (Enemy& e : es) {
		if (e.s != (e.s & ~b)) {
			e.h = true;
		}
		b = ~e.s & b;
	}

	sort(es.begin(), es.end(), [](const Enemy& a, const Enemy& b) { return a.i < b.i; });

	for (const Enemy& e : es) {
		cout << e.h << endl;
	}

	return 0;
}
0