Submission #35696627
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
map<int, set<int> > r, c;
int n, m, sx, sy, o, x, y, q, l;
char d;
int main()
{
cin >> n >> m >> sx >> sy >> o;
for (int i = 0; i < o; i++)
{
cin >> x >> y;
r[x].insert(y);
c[y].insert(x);
}
cin >> q;
for (int i = 0; i < q; i++)
{
cin >> d >> l;
if (d == 'L')
{
r[sx].insert(0);
int p = *--r[sx].upper_bound(sy);
sy = max(sy - l, p + 1);
}
else if (d == 'R')
{
r[sx].insert(m + 1);
int p = *r[sx].upper_bound(sy);
sy = min(sy + l, p - 1);
}
else if (d == 'U')
{
c[sy].insert(0);
int p = *--c[sy].upper_bound(sx);
sx = max(sx - l, p + 1);
}
else
{
c[sy].insert(n + 1);
int p = *c[sy].upper_bound(sx);
sx = min(sx + l, p - 1);
}
printf("%d %d\n", sx, sy);
}
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | D - LRUD Instructions |
| User | Factorio |
| Language | C++ (GCC 9.2.1) |
| Score | 400 |
| Code Size | 840 Byte |
| Status | AC |
| Exec Time | 1004 ms |
| Memory | 70216 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 400 / 400 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | example0.txt, example1.txt |
| All | 000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, 012.txt, 013.txt, 014.txt, 015.txt, 016.txt, 017.txt, 018.txt, 019.txt, 020.txt, 021.txt, 022.txt, 023.txt, 024.txt, 025.txt, 026.txt, example0.txt, example1.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 000.txt | AC | 384 ms | 3548 KiB |
| 001.txt | AC | 462 ms | 11568 KiB |
| 002.txt | AC | 390 ms | 3504 KiB |
| 003.txt | AC | 749 ms | 42012 KiB |
| 004.txt | AC | 730 ms | 41380 KiB |
| 005.txt | AC | 868 ms | 41972 KiB |
| 006.txt | AC | 837 ms | 41348 KiB |
| 007.txt | AC | 392 ms | 4440 KiB |
| 008.txt | AC | 1004 ms | 70216 KiB |
| 009.txt | AC | 181 ms | 17812 KiB |
| 010.txt | AC | 459 ms | 34484 KiB |
| 011.txt | AC | 518 ms | 45452 KiB |
| 012.txt | AC | 774 ms | 55192 KiB |
| 013.txt | AC | 962 ms | 67956 KiB |
| 014.txt | AC | 959 ms | 67900 KiB |
| 015.txt | AC | 975 ms | 67940 KiB |
| 016.txt | AC | 974 ms | 67928 KiB |
| 017.txt | AC | 657 ms | 22600 KiB |
| 018.txt | AC | 680 ms | 22636 KiB |
| 019.txt | AC | 693 ms | 22772 KiB |
| 020.txt | AC | 711 ms | 22912 KiB |
| 021.txt | AC | 707 ms | 23036 KiB |
| 022.txt | AC | 728 ms | 23016 KiB |
| 023.txt | AC | 715 ms | 23140 KiB |
| 024.txt | AC | 745 ms | 23032 KiB |
| 025.txt | AC | 732 ms | 23180 KiB |
| 026.txt | AC | 731 ms | 23108 KiB |
| example0.txt | AC | 5 ms | 3732 KiB |
| example1.txt | AC | 2 ms | 3628 KiB |