Submission #64661407
Source Code Expand
Copy
#include <stdio.h>#include <stdlib.h>#define MOD_BY 759149#define MULT 414157int get_hash(int x, int y) {return (int)((((long long)x * MULT + y) % MOD_BY + MOD_BY) % MOD_BY);}struct element_s {int x, y;struct element_s* next;};struct element_s* ht[MOD_BY];void ht_add(int x, int y) {int hash = get_hash(x, y);struct element_s** p = &ht[hash];while (*p != NULL) {
#include <stdio.h> #include <stdlib.h> #define MOD_BY 759149 #define MULT 414157 int get_hash(int x, int y) { return (int)((((long long)x * MULT + y) % MOD_BY + MOD_BY) % MOD_BY); } struct element_s { int x, y; struct element_s* next; }; struct element_s* ht[MOD_BY]; void ht_add(int x, int y) { int hash = get_hash(x, y); struct element_s** p = &ht[hash]; while (*p != NULL) { if ((*p)->x == x && (*p)->y == y) return; p = &(*p)->next; } *p = malloc(sizeof(**p)); if (*p == NULL) exit(2); **p = (struct element_s){ x, y, NULL }; } int ht_exists(int x, int y) { int hash = get_hash(x, y); struct element_s* p = ht[hash]; while (p != NULL) { if (p->x == x && p->y == y) return 1; p = p->next; } return 0; } int N, R, C; char S[212345]; int main(void) { int dx = 0, dy = 0; int i; if (scanf("%d%d%d", &N, &R, &C) != 3) return 1; if (scanf("%212344s", S) != 1) return 1; ht_add(0, 0); for (i = 0; i < N; i++) { switch (S[i]) { case 'N': dy++; break; case 'W': dx++; break; case 'S': dy--; break; case 'E': dx--; break; } ht_add(dx, dy); putchar('0' + ht_exists(C + dx, R + dy)); } putchar('\n'); return 0; } /* 逆にスポーンポイントと高橋君を移動させる */
Submission Info
Submission Time | |
---|---|
Task | D - Bonfire |
User | mikecat |
Language | C (gcc 12.2.0) |
Score | 425 |
Code Size | 1302 Byte |
Status | AC |
Exec Time | 15 ms |
Memory | 14032 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 425 / 425 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | sample_01.txt, sample_02.txt, sample_03.txt |
All | sample_01.txt, sample_02.txt, sample_03.txt, test_01.txt, test_02.txt, test_03.txt, test_04.txt, test_05.txt, test_06.txt, test_07.txt, test_08.txt, test_09.txt, test_10.txt, test_11.txt, test_12.txt, test_13.txt, test_14.txt, test_15.txt, test_16.txt, test_17.txt, test_18.txt, test_19.txt, test_20.txt, test_21.txt, test_22.txt, test_23.txt, test_24.txt, test_25.txt, test_26.txt, test_27.txt, test_28.txt, test_29.txt, test_30.txt, test_31.txt, test_32.txt, test_33.txt, test_34.txt, test_35.txt, test_36.txt, test_37.txt, test_38.txt, test_39.txt, test_40.txt, test_41.txt, test_42.txt, test_43.txt, test_44.txt, test_45.txt, test_46.txt, test_47.txt, test_48.txt, test_49.txt, test_50.txt, test_51.txt, test_52.txt, test_53.txt, test_54.txt, test_55.txt, test_56.txt, test_57.txt, test_58.txt, test_59.txt, test_60.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
sample_01.txt | AC | 0 ms | 1572 KB |
sample_02.txt | AC | 1 ms | 1544 KB |
sample_03.txt | AC | 0 ms | 1580 KB |
test_01.txt | AC | 7 ms | 6392 KB |
test_02.txt | AC | 8 ms | 6876 KB |
test_03.txt | AC | 8 ms | 6532 KB |
test_04.txt | AC | 0 ms | 1572 KB |
test_05.txt | AC | 7 ms | 5200 KB |
test_06.txt | AC | 8 ms | 6860 KB |
test_07.txt | AC | 7 ms | 5076 KB |
test_08.txt | AC | 0 ms | 1624 KB |
test_09.txt | AC | 7 ms | 6032 KB |
test_10.txt | AC | 6 ms | 4536 KB |
test_11.txt | AC | 6 ms | 4640 KB |
test_12.txt | AC | 0 ms | 1512 KB |
test_13.txt | AC | 7 ms | 5264 KB |
test_14.txt | AC | 8 ms | 6692 KB |
test_15.txt | AC | 7 ms | 5704 KB |
test_16.txt | AC | 1 ms | 1828 KB |
test_17.txt | AC | 7 ms | 5212 KB |
test_18.txt | AC | 7 ms | 5840 KB |
test_19.txt | AC | 7 ms | 5600 KB |
test_20.txt | AC | 2 ms | 3008 KB |
test_21.txt | AC | 8 ms | 6760 KB |
test_22.txt | AC | 7 ms | 4856 KB |
test_23.txt | AC | 7 ms | 5484 KB |
test_24.txt | AC | 7 ms | 6128 KB |
test_25.txt | AC | 8 ms | 9584 KB |
test_26.txt | AC | 8 ms | 9540 KB |
test_27.txt | AC | 8 ms | 9588 KB |
test_28.txt | AC | 7 ms | 9556 KB |
test_29.txt | AC | 13 ms | 13924 KB |
test_30.txt | AC | 14 ms | 13912 KB |
test_31.txt | AC | 13 ms | 13952 KB |
test_32.txt | AC | 13 ms | 13924 KB |
test_33.txt | AC | 7 ms | 9672 KB |
test_34.txt | AC | 8 ms | 9560 KB |
test_35.txt | AC | 7 ms | 9448 KB |
test_36.txt | AC | 9 ms | 9564 KB |
test_37.txt | AC | 13 ms | 13952 KB |
test_38.txt | AC | 13 ms | 13932 KB |
test_39.txt | AC | 12 ms | 14032 KB |
test_40.txt | AC | 13 ms | 13920 KB |
test_41.txt | AC | 9 ms | 7276 KB |
test_42.txt | AC | 12 ms | 12736 KB |
test_43.txt | AC | 11 ms | 13972 KB |
test_44.txt | AC | 14 ms | 13848 KB |
test_45.txt | AC | 9 ms | 10012 KB |
test_46.txt | AC | 8 ms | 6672 KB |
test_47.txt | AC | 9 ms | 10636 KB |
test_48.txt | AC | 9 ms | 7888 KB |
test_49.txt | AC | 10 ms | 12372 KB |
test_50.txt | AC | 13 ms | 12664 KB |
test_51.txt | AC | 13 ms | 11296 KB |
test_52.txt | AC | 10 ms | 10768 KB |
test_53.txt | AC | 12 ms | 11044 KB |
test_54.txt | AC | 15 ms | 13696 KB |
test_55.txt | AC | 14 ms | 13424 KB |
test_56.txt | AC | 10 ms | 12880 KB |
test_57.txt | AC | 10 ms | 12808 KB |
test_58.txt | AC | 10 ms | 11172 KB |
test_59.txt | AC | 10 ms | 10452 KB |
test_60.txt | AC | 10 ms | 9656 KB |