Submission #74016208
Source Code Expand
Copy
#include <stdio.h>#include <stdlib.h>int cmp(const void* x, const void* y) {long long a = *(const long long*)x, b = *(const long long*)y;return (a > b) - (a < b);}long long get_id(int y, int x) {return (long long)y * (1LL << 32) + x;}int idcnt;long long idlist[212345 * 4];int find_id(int y, int x) {long long id = get_id(y, x);int l = 0, r = idcnt - 1;while (l <= r) {int m = l + (r - l) / 2;if (idlist[m] == id) return m;
#include <stdio.h>
#include <stdlib.h>
int cmp(const void* x, const void* y) {
long long a = *(const long long*)x, b = *(const long long*)y;
return (a > b) - (a < b);
}
long long get_id(int y, int x) {
return (long long)y * (1LL << 32) + x;
}
int idcnt;
long long idlist[212345 * 4];
int find_id(int y, int x) {
long long id = get_id(y, x);
int l = 0, r = idcnt - 1;
while (l <= r) {
int m = l + (r - l) / 2;
if (idlist[m] == id) return m;
else if (idlist[m] < id) l = m + 1;
else r = m - 1;
}
printf("ERROR: (%d, %d) not found!\n", y, x);
exit(72);
}
int N, M;
int R[212345], C[212345];
char okareta[212345 * 4];
int main(void) {
int i;
int cnt = 0;
if (scanf("%d%d", &N, &M) != 2) return 1;
for (i = 0; i < M; i++) {
if (scanf("%d%d", &R[i], &C[i]) != 2) return 1;
idlist[i * 4 + 0] = get_id(R[i] + 0, C[i] + 0);
idlist[i * 4 + 1] = get_id(R[i] + 0, C[i] + 1);
idlist[i * 4 + 2] = get_id(R[i] + 1, C[i] + 0);
idlist[i * 4 + 3] = get_id(R[i] + 1, C[i] + 1);
}
qsort(idlist, M * 4, sizeof(*idlist), cmp);
for (i = 1, idcnt = 1; i < M * 4; i++) {
if (idlist[i] != idlist[idcnt - 1]) idlist[idcnt++] = idlist[i];
}
for (i = 0; i < M; i++) {
int id0 = find_id(R[i] + 0, C[i] + 0);
int id1 = find_id(R[i] + 0, C[i] + 1);
int id2 = find_id(R[i] + 1, C[i] + 0);
int id3 = find_id(R[i] + 1, C[i] + 1);
if (!okareta[id0] && !okareta[id1] && !okareta[id2] && !okareta[id3]) {
cnt++;
okareta[id0] = 1;
okareta[id1] = 1;
okareta[id2] = 1;
okareta[id3] = 1;
}
}
printf("%d\n", cnt);
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | C - 2x2 Placing |
| User | mikecat |
| Language | C23 (GCC 14.2.0) |
| Score | 300 |
| Code Size | 1622 Byte |
| Status | AC |
| Exec Time | 174 ms |
| Memory | 15668 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 300 / 300 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt |
| All | 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 02_random2_00.txt, 02_random2_01.txt, 02_random2_02.txt, 02_random2_03.txt, 02_random2_04.txt, 02_random2_05.txt, 02_random2_06.txt, 02_random2_07.txt, 02_random2_08.txt, 02_random2_09.txt, 02_random2_10.txt, 02_random2_11.txt, 02_random2_12.txt, 02_random2_13.txt, 02_random2_14.txt, 02_random2_15.txt, 03_handmade_00.txt, 03_handmade_01.txt, 03_handmade_02.txt, 03_handmade_03.txt, 03_handmade_04.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 00_sample_00.txt | AC | 0 ms | 1652 KiB |
| 00_sample_01.txt | AC | 0 ms | 1700 KiB |
| 00_sample_02.txt | AC | 0 ms | 1572 KiB |
| 01_random_00.txt | AC | 30 ms | 7076 KiB |
| 01_random_01.txt | AC | 55 ms | 14848 KiB |
| 01_random_02.txt | AC | 71 ms | 13008 KiB |
| 01_random_03.txt | AC | 126 ms | 15668 KiB |
| 01_random_04.txt | AC | 40 ms | 5376 KiB |
| 01_random_05.txt | AC | 144 ms | 15600 KiB |
| 01_random_06.txt | AC | 96 ms | 9808 KiB |
| 01_random_07.txt | AC | 174 ms | 15596 KiB |
| 01_random_08.txt | AC | 118 ms | 11288 KiB |
| 01_random_09.txt | AC | 170 ms | 15668 KiB |
| 01_random_10.txt | AC | 28 ms | 4532 KiB |
| 01_random_11.txt | AC | 160 ms | 15624 KiB |
| 02_random2_00.txt | AC | 161 ms | 15668 KiB |
| 02_random2_01.txt | AC | 161 ms | 15596 KiB |
| 02_random2_02.txt | AC | 159 ms | 15648 KiB |
| 02_random2_03.txt | AC | 160 ms | 15560 KiB |
| 02_random2_04.txt | AC | 160 ms | 15596 KiB |
| 02_random2_05.txt | AC | 159 ms | 15624 KiB |
| 02_random2_06.txt | AC | 160 ms | 15600 KiB |
| 02_random2_07.txt | AC | 160 ms | 15596 KiB |
| 02_random2_08.txt | AC | 161 ms | 15596 KiB |
| 02_random2_09.txt | AC | 162 ms | 15624 KiB |
| 02_random2_10.txt | AC | 160 ms | 15648 KiB |
| 02_random2_11.txt | AC | 162 ms | 15592 KiB |
| 02_random2_12.txt | AC | 157 ms | 15624 KiB |
| 02_random2_13.txt | AC | 152 ms | 15604 KiB |
| 02_random2_14.txt | AC | 144 ms | 15616 KiB |
| 02_random2_15.txt | AC | 124 ms | 15652 KiB |
| 03_handmade_00.txt | AC | 55 ms | 14828 KiB |
| 03_handmade_01.txt | AC | 80 ms | 12496 KiB |
| 03_handmade_02.txt | AC | 87 ms | 15624 KiB |
| 03_handmade_03.txt | AC | 83 ms | 15568 KiB |
| 03_handmade_04.txt | AC | 85 ms | 15668 KiB |