Submission #66008437
Source Code Expand
Copy
#include <stdio.h>#include <stdlib.h>int N, M, Q;int query[212345][3];struct kengen_s {int user, page;};int cmp(const void* x, const void* y) {struct kengen_s a = *(const struct kengen_s*)x, b = *(const struct kengen_s*)y;if (a.user != b.user) return a.user < b.user ? -1 : 1;return a.page < b.page ? -1 : a.page > b.page;}int zac = 0;struct kengen_s zal[212345];char is_ok[212345];char is_allok[212345];
#include <stdio.h> #include <stdlib.h> int N, M, Q; int query[212345][3]; struct kengen_s { int user, page; }; int cmp(const void* x, const void* y) { struct kengen_s a = *(const struct kengen_s*)x, b = *(const struct kengen_s*)y; if (a.user != b.user) return a.user < b.user ? -1 : 1; return a.page < b.page ? -1 : a.page > b.page; } int zac = 0; struct kengen_s zal[212345]; char is_ok[212345]; char is_allok[212345]; int get_id(int user, int page) { struct kengen_s query = { user, page }; int l = 0, r = zac - 1; while (l <= r) { int m = l + (r - l) / 2; int c = cmp(&zal[m], &query); if (c == 0) return m; if (c < 0) l = m + 1; else r = m - 1; } return zac; } int main(void) { int i; int zac_raw = 0; if (scanf("%d%d%d", &N, &M, &Q) != 3) return 1; for (i = 1; i <= Q; i++) { if (scanf("%d%d", &query[i][0], &query[i][1]) != 2) return 1; if (query[i][0] != 2) { if (scanf("%d", &query[i][2]) != 1) return 1; } } /* 座標圧縮 */ for (i = 1; i <= Q; i++) { if (query[i][0] == 1) { zal[zac_raw++] = (struct kengen_s){ query[i][1], query[i][2] }; } } qsort(zal, zac_raw, sizeof(*zal), cmp); zac = zac_raw > 0; for (i = 1; i < zac_raw; i++) { if (zal[zac - 1].user != zal[i].user || zal[zac - 1].page != zal[i].page) { zal[zac++] = zal[i]; } } for (i = 1; i <= Q; i++) { switch (query[i][0]) { case 1: { int id = get_id(query[i][1], query[i][2]); if (id >= zac) { puts("ERROR!!!!!"); return 42; } is_ok[id] = 1; } break; case 2: is_allok[query[i][1]] = 1; break; case 3: { int id = get_id(query[i][1], query[i][2]); puts(is_allok[query[i][1]] || (id < zac && is_ok[id]) ? "Yes" : "No"); } break; } } return 0; }
Submission Info
Submission Time | |
---|---|
Task | C - 403 Forbidden |
User | mikecat |
Language | C (gcc 12.2.0) |
Score | 300 |
Code Size | 1852 Byte |
Status | AC |
Exec Time | 75 ms |
Memory | 5520 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 300 / 300 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 00_sample_01.txt, 00_sample_02.txt |
All | 00_sample_01.txt, 00_sample_02.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, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt, 01_random_19.txt, 01_random_20.txt, 01_random_21.txt, 01_random_22.txt, 01_random_23.txt, 01_random_24.txt, 01_random_25.txt, 01_random_26.txt, 01_random_27.txt, 01_random_28.txt, 01_random_29.txt, 01_random_30.txt, 01_random_31.txt, 01_random_32.txt, 01_random_33.txt, 01_random_34.txt, 01_random_35.txt, 01_random_36.txt, 02_handmade_01.txt, 02_handmade_02.txt, 02_handmade_03.txt, 02_handmade_04.txt, 02_handmade_05.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
00_sample_01.txt | AC | 0 ms | 1628 KB |
00_sample_02.txt | AC | 1 ms | 1504 KB |
01_random_01.txt | AC | 42 ms | 4908 KB |
01_random_02.txt | AC | 50 ms | 5172 KB |
01_random_03.txt | AC | 52 ms | 5520 KB |
01_random_04.txt | AC | 26 ms | 3916 KB |
01_random_05.txt | AC | 47 ms | 4852 KB |
01_random_06.txt | AC | 56 ms | 5248 KB |
01_random_07.txt | AC | 59 ms | 5320 KB |
01_random_08.txt | AC | 27 ms | 3828 KB |
01_random_09.txt | AC | 53 ms | 4792 KB |
01_random_10.txt | AC | 65 ms | 5164 KB |
01_random_11.txt | AC | 69 ms | 5476 KB |
01_random_12.txt | AC | 29 ms | 3892 KB |
01_random_13.txt | AC | 50 ms | 4956 KB |
01_random_14.txt | AC | 60 ms | 5172 KB |
01_random_15.txt | AC | 64 ms | 5472 KB |
01_random_16.txt | AC | 28 ms | 3888 KB |
01_random_17.txt | AC | 52 ms | 4928 KB |
01_random_18.txt | AC | 64 ms | 5056 KB |
01_random_19.txt | AC | 68 ms | 5432 KB |
01_random_20.txt | AC | 28 ms | 3968 KB |
01_random_21.txt | AC | 55 ms | 4944 KB |
01_random_22.txt | AC | 68 ms | 5200 KB |
01_random_23.txt | AC | 73 ms | 5456 KB |
01_random_24.txt | AC | 30 ms | 3980 KB |
01_random_25.txt | AC | 54 ms | 4908 KB |
01_random_26.txt | AC | 66 ms | 5052 KB |
01_random_27.txt | AC | 69 ms | 5384 KB |
01_random_28.txt | AC | 32 ms | 4076 KB |
01_random_29.txt | AC | 55 ms | 4900 KB |
01_random_30.txt | AC | 66 ms | 5164 KB |
01_random_31.txt | AC | 71 ms | 5320 KB |
01_random_32.txt | AC | 33 ms | 4168 KB |
01_random_33.txt | AC | 59 ms | 4948 KB |
01_random_34.txt | AC | 70 ms | 5176 KB |
01_random_35.txt | AC | 75 ms | 5376 KB |
01_random_36.txt | AC | 35 ms | 4172 KB |
02_handmade_01.txt | AC | 0 ms | 1568 KB |
02_handmade_02.txt | AC | 1 ms | 1620 KB |
02_handmade_03.txt | AC | 67 ms | 5444 KB |
02_handmade_04.txt | AC | 66 ms | 5376 KB |
02_handmade_05.txt | AC | 52 ms | 4840 KB |