Submission #60964452
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
int main() {
long long N, M, Sx, Sy;
cin >> N >> M >> Sx >> Sy;
set<pair<long long, long long>> houses;
for (long long i = 0; i < N; i++) {
long long x, y;
cin >> x >> y;
houses.insert({x, y});
}
long long x = Sx, y = Sy;
set<pair<long long, long long>> passedHouses;
for (long long i = 0; i < M; i++) {
char direction;
long long distance;
cin >> direction >> distance;
long long newX = x, newY = y;
if (direction == 'U') {
newY += distance;
} else if (direction == 'D') {
newY -= distance;
} else if (direction == 'L') {
newX -= distance;
} else if (direction == 'R') {
newX += distance;
}
if (direction == 'U' || direction == 'D') {
long long step = (newY > y) ? 1 : -1;
for (long long j = y; j != newY + step; j += step) {
if (houses.count({x, j})) {
passedHouses.insert({x, j});
}
}
} else {
long long step = (newX > x) ? 1 : -1;
for (long long j = x; j != newX + step; j += step) {
if (houses.count({j, y})) {
passedHouses.insert({j, y});
}
}
}
x = newX;
y = newY;
}
cout << x << " " << y << " " << passedHouses.size() << endl;
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | D - Santa Claus 2 |
| User | inspector_05 |
| Language | C++ 17 (gcc 12.2) |
| Score | 0 |
| Code Size | 1563 Byte |
| Status | TLE |
| Exec Time | 2209 ms |
| Memory | 28148 KiB |
Judge Result
| Set Name | Sample | All | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 0 / 425 | ||||||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | sample_01.txt, sample_02.txt |
| All | hand.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, sample_01.txt, sample_02.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| hand.txt | AC | 1 ms | 3400 KiB |
| random_01.txt | TLE | 2207 ms | 3252 KiB |
| random_02.txt | TLE | 2207 ms | 3304 KiB |
| random_03.txt | TLE | 2207 ms | 3440 KiB |
| random_04.txt | TLE | 2208 ms | 16308 KiB |
| random_05.txt | TLE | 2208 ms | 16380 KiB |
| random_06.txt | TLE | 2207 ms | 6636 KiB |
| random_07.txt | TLE | 2208 ms | 11460 KiB |
| random_08.txt | TLE | 2208 ms | 12980 KiB |
| random_09.txt | TLE | 2208 ms | 14580 KiB |
| random_10.txt | TLE | 2207 ms | 5484 KiB |
| random_11.txt | TLE | 2208 ms | 15804 KiB |
| random_12.txt | TLE | 2208 ms | 15952 KiB |
| random_13.txt | TLE | 2208 ms | 15808 KiB |
| random_14.txt | TLE | 2209 ms | 28060 KiB |
| random_15.txt | TLE | 2208 ms | 15844 KiB |
| random_16.txt | TLE | 2208 ms | 15692 KiB |
| random_17.txt | TLE | 2208 ms | 15816 KiB |
| random_18.txt | TLE | 2209 ms | 28044 KiB |
| random_19.txt | TLE | 2208 ms | 15708 KiB |
| random_20.txt | TLE | 2208 ms | 15952 KiB |
| random_21.txt | TLE | 2208 ms | 15776 KiB |
| random_22.txt | TLE | 2209 ms | 28148 KiB |
| sample_01.txt | AC | 1 ms | 3488 KiB |
| sample_02.txt | TLE | 2207 ms | 3348 KiB |