結果

問題 No.678 2Dシューティングゲームの必殺ビーム
ユーザー Mcpu3Mcpu3
提出日時 2018-12-08 10:46:36
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,131 bytes
コンパイル時間 599 ms
コンパイル使用メモリ 70,832 KB
実行使用メモリ 4,352 KB
最終ジャッジ日時 2023-10-12 04:54:59
合計ジャッジ時間 1,489 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

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

struct enemy {
	int XL, XR, YD, ans, order;
};

bool compYD(const enemy &x, const enemy &y) {
	return x.YD > y.YD;
}

bool compOrder(const enemy &x, const enemy &y) {
	return x.order < y.order;
}

int main() {
	int N, xLB, xRB, width[1280] = {}, j;
	enemy hitJudge[188];
	cin >> N >> xLB >> xRB;
	for (int i = xLB; i <= xRB; ++i) width[i - 1] = 1;
	for (int i = 0; i < N; ++i) {
		scanf("%d%*d%d%d", &hitJudge[i].XL, &hitJudge[i].XR, &hitJudge[i].YD);
		if (hitJudge[i].XL < 1) hitJudge[i].XL = 1;
		if (hitJudge[i].XR > 1280) hitJudge[i].XR = 1280;
		hitJudge[i].order = i;
	}
	sort(hitJudge, hitJudge + N, compYD);
	for (int i = 0; i < N; ++i) {
		for (j = hitJudge[i].XL; j <= hitJudge[i].XR; ++j) {
			if (width[j - 1] == 1) break;
		}
		if (j != hitJudge[i].XR + 1) {
			for (j = hitJudge[i].XL; j <= hitJudge[i].XR; ++j) width[j - 1] = 0;
			hitJudge[i].ans = 1;
		}
		else hitJudge[i].ans = 0;
	}
	sort(hitJudge, hitJudge + N, compOrder);
	for (int i = 0; i < N; ++i) cout << hitJudge[i].ans << endl;
}
0