結果
| 問題 | No.678 2Dシューティングゲームの必殺ビーム | 
| コンテスト | |
| ユーザー |  bal4u | 
| 提出日時 | 2019-08-19 14:56:07 | 
| 言語 | C (gcc 13.3.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 1 ms / 2,000 ms | 
| コード長 | 1,297 bytes | 
| コンパイル時間 | 179 ms | 
| コンパイル使用メモリ | 31,360 KB | 
| 実行使用メモリ | 6,824 KB | 
| 最終ジャッジ日時 | 2024-10-04 09:18:29 | 
| 合計ジャッジ時間 | 851 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 18 | 
コンパイルメッセージ
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');
      |                                 ^~
            
            ソースコード
// 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;
}
            
            
            
        