提出 #41762485
ソースコード 拡げる
Copy
Copy
- #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;
- }
#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;
}
提出情報
提出日時 |
|
問題 |
C - Dash |
ユーザ |
mikecat |
言語 |
C (GCC 9.2.1) |
得点 |
300 |
コード長 |
1113 Byte |
結果 |
AC |
実行時間 |
84 ms |
メモリ |
6164 KB |
ジャッジ結果
セット名 |
Sample |
All |
得点 / 配点 |
0 / 0 |
300 / 300 |
結果 |
|
|
セット名 |
テストケース |
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 |
ケース名 |
結果 |
実行時間 |
メモリ |
00_sample_01.txt |
AC |
5 ms |
1604 KB |
00_sample_02.txt |
AC |
1 ms |
1632 KB |
01_test_01.txt |
AC |
84 ms |
6164 KB |
01_test_02.txt |
AC |
54 ms |
3828 KB |
01_test_03.txt |
AC |
54 ms |
3884 KB |
01_test_04.txt |
AC |
4 ms |
1792 KB |
01_test_05.txt |
AC |
8 ms |
1804 KB |
01_test_06.txt |
AC |
8 ms |
1700 KB |
01_test_07.txt |
AC |
7 ms |
1752 KB |
01_test_08.txt |
AC |
9 ms |
1752 KB |
01_test_09.txt |
AC |
10 ms |
1796 KB |
01_test_10.txt |
AC |
3 ms |
1792 KB |
01_test_11.txt |
AC |
5 ms |
1872 KB |
01_test_12.txt |
AC |
8 ms |
1780 KB |
01_test_13.txt |
AC |
8 ms |
1784 KB |
01_test_14.txt |
AC |
8 ms |
1780 KB |
01_test_15.txt |
AC |
8 ms |
1692 KB |
01_test_16.txt |
AC |
8 ms |
1796 KB |
01_test_17.txt |
AC |
6 ms |
1696 KB |
01_test_18.txt |
AC |
6 ms |
1792 KB |