結果

問題 No.202 1円玉投げ
ユーザー bal4ubal4u
提出日時 2019-06-28 22:42:55
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 28 ms / 5,000 ms
コード長 1,285 bytes
コンパイル時間 141 ms
コンパイル使用メモリ 30,728 KB
実行使用メモリ 8,508 KB
最終ジャッジ日時 2023-08-24 00:02:09
合計ジャッジ時間 2,160 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 21 ms
5,220 KB
testcase_01 AC 25 ms
8,508 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,384 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 4 ms
5,032 KB
testcase_06 AC 23 ms
7,776 KB
testcase_07 AC 25 ms
7,948 KB
testcase_08 AC 25 ms
8,068 KB
testcase_09 AC 14 ms
6,652 KB
testcase_10 AC 6 ms
5,548 KB
testcase_11 AC 12 ms
6,444 KB
testcase_12 AC 12 ms
6,396 KB
testcase_13 AC 7 ms
5,648 KB
testcase_14 AC 3 ms
5,108 KB
testcase_15 AC 14 ms
6,580 KB
testcase_16 AC 17 ms
5,080 KB
testcase_17 AC 16 ms
6,684 KB
testcase_18 AC 17 ms
6,688 KB
testcase_19 AC 13 ms
6,484 KB
testcase_20 AC 20 ms
7,368 KB
testcase_21 AC 13 ms
6,452 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 2 ms
4,380 KB
testcase_25 AC 2 ms
4,376 KB
testcase_26 AC 3 ms
4,792 KB
testcase_27 AC 3 ms
4,728 KB
testcase_28 AC 2 ms
4,380 KB
testcase_29 AC 2 ms
4,380 KB
testcase_30 AC 3 ms
4,596 KB
testcase_31 AC 2 ms
4,376 KB
testcase_32 AC 3 ms
4,468 KB
testcase_33 AC 2 ms
4,380 KB
testcase_34 AC 3 ms
4,376 KB
testcase_35 AC 21 ms
6,388 KB
testcase_36 AC 20 ms
4,600 KB
testcase_37 AC 28 ms
8,252 KB
testcase_38 AC 20 ms
6,356 KB
testcase_39 AC 2 ms
4,376 KB
testcase_40 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: 関数 ‘in’ 内:
main.c:9:14: 警告: 関数 ‘getchar_unlocked’ の暗黙的な宣言です [-Wimplicit-function-declaration]
    9 | #define gc() getchar_unlocked()
      |              ^~~~~~~~~~~~~~~~
main.c:15:24: 備考: in expansion of macro ‘gc’
   15 |         int n = 0, c = gc();
      |                        ^~

ソースコード

diff #

// yukicoder: No.202 1円玉投げ
// 2019.6.28 bal4u

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

#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif
int in()
{
	int n = 0, c = gc();
	do n = 10 * n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

int *p[505][505], hi[505][505]; int N;
int mv[9][2] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,0},{0,1},{1,-1},{1,0},{1,1}};
int x[100005], y[100005];
char f[100005];

int main()
{
	int i, j, k, t, r, c, rr, cc, ans;

	ans = N = in();
	memset(f, 1, N);
	for (i = 0; i < N; i++) {
		x[i] = in(), y[i] = in();
		hi[1+y[i]/40][1+x[i]/40]++;
	}
	for (r = 1; r <= 501; r++) for (c = 1; c <= 501; c++) if (hi[r][c]) {
		p[r][c] = malloc(hi[r][c] * sizeof(int));
	}
	
	memset(hi, 0, sizeof(hi));
		
	for (i = 0; i < N; i++) {
		r = 1+y[i]/40, c = 1+x[i]/40;
		k = hi[r][c]++;
		p[r][c][k] = i;
	}
	
	for (i = 0; i < N; i++) if (f[i]) {
		r = 1+y[i]/40, c = 1+x[i]/40;
		
		for (j = 0; j < 9; j++) {
			rr = r + mv[j][0], cc = c + mv[j][1];
			for (k = 0; k < hi[rr][cc]; k++) if (f[t = p[rr][cc][k]] && t != i) {
				int dx = x[i] - x[t], dy = y[i] - y[t];
				if (dx*dx + dy*dy < 400) { 
					ans--, f[t] = 0, p[rr][cc][k] = p[rr][cc][--hi[rr][cc]], k--;
				}
			}
		}
	}
	printf("%d\n", ans);
	return 0;
}
0