結果

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

テストケース

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

ソースコード

diff #

#include <stdio.h>
#include <stdlib.h>

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

int compYD(const void *x, const void *y)
{
	return ((enemy*)y)->YD - ((enemy*)x)->YD;
}

int compOrder(const void *x, const void *y)
{
	return ((enemy*)x)->order - ((enemy*)y)->order;
}

int main(void)
{
	int N, xLB, xRB, width[1280] = {}, i, j;
	enemy hitJudge[188];
	scanf("%d%d%d", &N, &xLB, &xRB);
	for (i = xLB; i <= xRB; ++i) width[i - 1] = 1;
	for (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;
	}
	qsort(hitJudge, N, sizeof(enemy), compYD);
	for (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;
	}
	qsort(hitJudge, N, sizeof(enemy), compOrder);
	for (i = 0; i < N; ++i) printf("%d\n", hitJudge[i].ans);
	return 0;
}
0