Submission #45494270
Source Code Expand
/*
Author: Denys Smirnov
Time: 2023-09-12 23:51:51
*/
#include "bits/stdc++.h"
#ifdef DENDI239
#define D \
for (bool _flag_dendi239 = true; _flag_dendi239; _flag_dendi239 = false)
#else
#define D while (false)
#endif
using namespace std;
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n, m, h, k;
cin >> n >> m >> h >> k;
set<pair<int, int>> heal;
string s;
cin >> s;
for (int i = 0; i < m; ++i) {
int x, y;
cin >> x >> y;
heal.insert({x, y});
}
int x = 0, y = 0;
for (char c : s) {
h -= 1;
switch (c) {
case 'L':
x -= 1;
break;
case 'R':
x += 1;
break;
case 'D':
y -= 1;
break;
case 'U':
y += 1;
break;
}
if (h < 0) break;
if (h < k && heal.count({x, y})) {
h = k;
heal.erase({x, y});
}
}
cout << (h >= 0 ? "Yes" : "No") << '\n';
}
Submission Info
| Submission Time | |
|---|---|
| Task | C - Dash |
| User | dendi239 |
| Language | C++ 20 (gcc 12.2) |
| Score | 300 |
| Code Size | 995 Byte |
| Status | AC |
| Exec Time | 85 ms |
| Memory | 12948 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 | 1 ms | 3400 KiB |
| 00_sample_02.txt | AC | 1 ms | 3628 KiB |
| 01_test_01.txt | AC | 85 ms | 12948 KiB |
| 01_test_02.txt | AC | 39 ms | 8120 KiB |
| 01_test_03.txt | AC | 39 ms | 8172 KiB |
| 01_test_04.txt | AC | 1 ms | 3628 KiB |
| 01_test_05.txt | AC | 2 ms | 3484 KiB |
| 01_test_06.txt | AC | 3 ms | 3696 KiB |
| 01_test_07.txt | AC | 3 ms | 3700 KiB |
| 01_test_08.txt | AC | 4 ms | 3700 KiB |
| 01_test_09.txt | AC | 4 ms | 3568 KiB |
| 01_test_10.txt | AC | 1 ms | 3624 KiB |
| 01_test_11.txt | AC | 2 ms | 3636 KiB |
| 01_test_12.txt | AC | 3 ms | 3624 KiB |
| 01_test_13.txt | AC | 3 ms | 3680 KiB |
| 01_test_14.txt | AC | 3 ms | 3564 KiB |
| 01_test_15.txt | AC | 3 ms | 3756 KiB |
| 01_test_16.txt | AC | 3 ms | 3684 KiB |
| 01_test_17.txt | AC | 3 ms | 3628 KiB |
| 01_test_18.txt | AC | 3 ms | 3752 KiB |