Submission #60956315
Source Code Expand
Copy
#include <iostream>#include <map>#include <set>#include <vector>#include <string>#include <tuple>using namespace std;using ll = long long;int main() {// 入力ll N, M, Sx, Sy;cin >> N >> M >> Sx >> Sy;map<ll, set<ll>> x_to_y, y_to_x;for (ll i = 0; i < N; ++i) {ll x, y;cin >> x >> y;x_to_y[x].insert(y);y_to_x[y].insert(x);
#include <iostream>
#include <map>
#include <set>
#include <vector>
#include <string>
#include <tuple>
using namespace std;
using ll = long long;
int main() {
// 入力
ll N, M, Sx, Sy;
cin >> N >> M >> Sx >> Sy;
map<ll, set<ll>> x_to_y, y_to_x;
for (ll i = 0; i < N; ++i) {
ll x, y;
cin >> x >> y;
x_to_y[x].insert(y);
y_to_x[y].insert(x);
}
vector<pair<char, ll>> moves(M);
for (ll i = 0; i < M; ++i) {
char d;
ll c;
cin >> d >> c;
moves[i] = {d, c};
}
ll x = Sx, y = Sy;
set<pair<ll, ll>> visited;
for (const auto &[dir, dist] : moves) {
if (dir == 'U' || dir == 'D') {
ll sign = (dir == 'U') ? 1 : -1;
ll ny = y + sign * dist;
auto &x_coords = x_to_y[x];
auto it_low = x_coords.lower_bound(min(y, ny));
auto it_high = x_coords.upper_bound(max(y, ny));
for (auto it = it_low; it != it_high; ++it) {
visited.insert({x, *it});
}
y = ny;
} else if (dir == 'L' || dir == 'R') {
ll sign = (dir == 'R') ? 1 : -1;
ll nx = x + sign * dist;
auto &y_coords = y_to_x[y];
auto it_low = y_coords.lower_bound(min(x, nx));
auto it_high = y_coords.upper_bound(max(x, nx));
for (auto it = it_low; it != it_high; ++it) {
visited.insert({*it, y});
}
x = nx;
}
}
// 出力
cout << x << " " << y << " " << visited.size() << endl;
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | D - Santa Claus 2 |
| User | VIP1109 |
| Language | C++ 20 (gcc 12.2) |
| Score | 0 |
| Code Size | 1681 Byte |
| Status | TLE |
| Exec Time | 2209 ms |
| Memory | 61188 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 | 3496 KiB |
| random_01.txt | AC | 63 ms | 6220 KiB |
| random_02.txt | AC | 63 ms | 6288 KiB |
| random_03.txt | AC | 64 ms | 6312 KiB |
| random_04.txt | AC | 276 ms | 42756 KiB |
| random_05.txt | AC | 317 ms | 49068 KiB |
| random_06.txt | AC | 1461 ms | 18380 KiB |
| random_07.txt | AC | 1164 ms | 33744 KiB |
| random_08.txt | AC | 329 ms | 53036 KiB |
| random_09.txt | AC | 393 ms | 61188 KiB |
| random_10.txt | AC | 116 ms | 22916 KiB |
| random_11.txt | AC | 969 ms | 35260 KiB |
| random_12.txt | AC | 1707 ms | 36644 KiB |
| random_13.txt | AC | 279 ms | 27608 KiB |
| random_14.txt | AC | 1827 ms | 36428 KiB |
| random_15.txt | TLE | 2209 ms | 36880 KiB |
| random_16.txt | TLE | 2199 ms | 37436 KiB |
| random_17.txt | TLE | 2209 ms | 37040 KiB |
| random_18.txt | AC | 1824 ms | 36168 KiB |
| random_19.txt | TLE | 2209 ms | 37144 KiB |
| random_20.txt | AC | 488 ms | 34032 KiB |
| random_21.txt | TLE | 2022 ms | 36460 KiB |
| random_22.txt | TLE | 2209 ms | 37560 KiB |
| sample_01.txt | AC | 1 ms | 3496 KiB |
| sample_02.txt | AC | 1 ms | 3476 KiB |