Submission #41762485
Source Code Expand
Copy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#include <stdio.h>
#include <stdlib.h>
struct item_s {
int x, y;
char used;
};
int cmp(const void* x, const void* y) {
struct item_s a = *(const struct item_s*)x, b = *(const struct item_s*)y;
if (a.y != b.y) return a.y < b.y ? -1 : 1;
return a.x < b.x ? -1 : a.x > b.x;
}
int N, M, H, K;
char S[212345];
struct item_s items[212345];
int main(void) {
int i;
int x = 0, y = 0, t;
if (scanf("%d%d%d%d", &N, &M, &H, &K) != 4) return 1;
if (scanf("%212344s", S) != 1) return 1;
for (i = 0; i < M; i++) {
if (scanf("%d%d", &items[i].x, &items[i].y) != 2) return 1;
items[i].used = 0;
}
qsort(items, M, sizeof(*items), cmp);
t = H;
for (i = 0; i < N; i++) {
struct item_s q, *r;
switch (S[i]) {
case 'R': x++; break;
case 'L': x--; break;
case 'U': y++; break;
case 'D': y--; break;
}
t--;
if (t < 0) {
puts("No");
return 0;
}
q.x = x;
q.y = y;
q.used = 0;
r = bsearch(&q, items, M, sizeof(*items), cmp);
if (r != NULL && !r->used && t < K) {
r->used = 1;
t = K;
}
}
puts("Yes");
return 0;
}
Submission Info
Submission Time |
|
Task |
C - Dash |
User |
mikecat |
Language |
C (GCC 9.2.1) |
Score |
300 |
Code Size |
1113 Byte |
Status |
AC |
Exec Time |
84 ms |
Memory |
6164 KiB |
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_test_01.txt, 01_test_02.txt, 01_test_03.txt, 01_test_04.txt, 01_test_05.txt, 01_test_06.txt, 01_test_07.txt, 01_test_08.txt, 01_test_09.txt, 01_test_10.txt, 01_test_11.txt, 01_test_12.txt, 01_test_13.txt, 01_test_14.txt, 01_test_15.txt, 01_test_16.txt, 01_test_17.txt, 01_test_18.txt |
Case Name |
Status |
Exec Time |
Memory |
00_sample_01.txt |
AC |
5 ms |
1604 KiB |
00_sample_02.txt |
AC |
1 ms |
1632 KiB |
01_test_01.txt |
AC |
84 ms |
6164 KiB |
01_test_02.txt |
AC |
54 ms |
3828 KiB |
01_test_03.txt |
AC |
54 ms |
3884 KiB |
01_test_04.txt |
AC |
4 ms |
1792 KiB |
01_test_05.txt |
AC |
8 ms |
1804 KiB |
01_test_06.txt |
AC |
8 ms |
1700 KiB |
01_test_07.txt |
AC |
7 ms |
1752 KiB |
01_test_08.txt |
AC |
9 ms |
1752 KiB |
01_test_09.txt |
AC |
10 ms |
1796 KiB |
01_test_10.txt |
AC |
3 ms |
1792 KiB |
01_test_11.txt |
AC |
5 ms |
1872 KiB |
01_test_12.txt |
AC |
8 ms |
1780 KiB |
01_test_13.txt |
AC |
8 ms |
1784 KiB |
01_test_14.txt |
AC |
8 ms |
1780 KiB |
01_test_15.txt |
AC |
8 ms |
1692 KiB |
01_test_16.txt |
AC |
8 ms |
1796 KiB |
01_test_17.txt |
AC |
6 ms |
1696 KiB |
01_test_18.txt |
AC |
6 ms |
1792 KiB |