結果

問題 No.678 2Dシューティングゲームの必殺ビーム
ユーザー bal4ubal4u
提出日時 2019-08-19 14:56:07
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 1,297 bytes
コンパイル時間 204 ms
コンパイル使用メモリ 31,744 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-15 01:43:21
合計ジャッジ時間 844 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,816 KB
testcase_01 AC 1 ms
6,944 KB
testcase_02 AC 1 ms
6,944 KB
testcase_03 AC 1 ms
6,940 KB
testcase_04 AC 1 ms
6,940 KB
testcase_05 AC 1 ms
6,944 KB
testcase_06 AC 1 ms
6,944 KB
testcase_07 AC 1 ms
6,940 KB
testcase_08 AC 1 ms
6,940 KB
testcase_09 AC 1 ms
6,940 KB
testcase_10 AC 1 ms
6,944 KB
testcase_11 AC 1 ms
6,940 KB
testcase_12 AC 1 ms
6,944 KB
testcase_13 AC 1 ms
6,944 KB
testcase_14 AC 1 ms
6,944 KB
testcase_15 AC 1 ms
6,940 KB
testcase_16 AC 1 ms
6,944 KB
testcase_17 AC 1 ms
6,940 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function 'in':
main.c:10:14: warning: implicit declaration of function 'getchar_unlocked' [-Wimplicit-function-declaration]
   10 | #define gc() getchar_unlocked()
      |              ^~~~~~~~~~~~~~~~
main.c:19:24: note: in expansion of macro 'gc'
   19 |         int n = 0, c = gc();
      |                        ^~
main.c: In function 'main':
main.c:11:15: warning: implicit declaration of function 'putchar_unlocked' [-Wimplicit-function-declaration]
   11 | #define pc(c) putchar_unlocked(c)
      |               ^~~~~~~~~~~~~~~~
main.c:55:33: note: in expansion of macro 'pc'
   55 |         for (i = 0; i < N; i++) pc('0'+ans[i]), pc('\n');
      |                                 ^~

ソースコード

diff #

// yukicoder: No.678 2Dシューティングゲームの必殺ビーム
// bal4u 2019.8.19

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

//// 入出力関係
#if 1
#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)
#else
#define gc() getchar()
#define pc(c) putchar(c)
#endif

int in()   // 整数の入力(負数対応)
{
	int n = 0, c = gc();
	if (c == '-') {	c = gc();
		do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
		return -n;
	}
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

typedef struct { int xl, xr, yu, yd, id; } T;
T tbl[200]; int N;
char ans[200];
char beam[1300];

int cmp(const void *u, const void *v) { return ((T *)v)->yd - ((T *)u)->yd; }
 
int main()
{
	int i, xl, xr, yu, yd, x, f;

	N = in(), xl = in(), xr = in(), memset(beam+xl, 1, xr-xl+1);
	for (i = 0; i < N; i++) {
		xl = in(), yu = in(), xr = in(), yd = in();
		if (xl < 0) xl = 0;
		if (xr > 1280) xr = 1280;
		tbl[i].xl = xl, tbl[i].xr = xr, tbl[i].yu = yu, tbl[i].yd = yd, tbl[i].id = i;
	}
	qsort(tbl, N, sizeof(T), cmp);
	for (i = 0; i < N; i++) {
		f = 0;
		xl = tbl[i].xl, xr = tbl[i].xr;
		for (x = xl; x <= xr; x++) {
			if (beam[x]) f = 1, beam[x] = 0;
		}
		ans[tbl[i].id] = f;
	}
	for (i = 0; i < N; i++) pc('0'+ans[i]), pc('\n');
	return 0;
}
0