提出 #45018373
ソースコード 拡げる
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> Pair;
#define vi vector<int>
#define vs vector<string>
#define vc vector<char>
#define vl vector<ll>
#define vb vector<bool>
#define vd vector<double>
#define vp vector<Pair>
#define vvi vector<vector<int>>
#define vvc vector<vector<char>>
#define vvl vector<vector<ll>>
#define vvb vector<vector<bool>>
#define vvd vector<vector<double>>
#define vvvi vector<vector<vector<int>>>
#define vvvl vector<vector<vector<ll>>>
#define vvvb vector<vector<vector<bool>>>
#define ql queue<ll>
#define dql deque<ll>
#define pql priority_queue<ll>
#define pqla priority_queue<ll,vl,greater<ll>>
#define mll map<ll, ll>
#define rep(i, N) for (ll i=0; i<(ll)(N); i++)
#define repr(i, N) for (ll i = (ll)(N) - 1; i >= 0; i--)
#define repk(i, k, N) for (ll i = k; i < (ll)(N); i++)
#define rep1(i, N) for (ll i=1; i<(ll)(N+1); i++)
#define all(v) (v).begin(), (v).end()
#define allr(v) (v).rbegin(), (v).rend()
#define SIZE(v) (ll)((v).size())
template<typename T> inline bool chmax(T &a, T b) { return ((a < b) ? (a = b, true) : (false)); }
template<typename T> inline bool chmin(T &a, T b) { return ((a > b) ? (a = b, true) : (false)); }
const ll INF = 3e18;
const double PI = 3.14159265358979323846264338327950288419716939937510582097494459230781640628;
ll n_left (set<ll> st, ll x) {
if (SIZE(st) == 0) return -INF;
auto itr = st.upper_bound(x);
if (itr != st.begin()) return *(--itr);
return -INF;
}
ll n_right (set<ll> st, ll x) {
if (SIZE(st) == 0) return INF;
auto itr = st.upper_bound(x);
if (itr != st.end()) return *itr;
return INF;
}
int main () {
ll H, W; cin >> H >> W;
ll rs, cs; cin >> rs >> cs; --rs; --cs;
ll N; cin >> N;
vector<set<ll>> obj_r(H), obj_c(W);
rep (i, N) {
ll r, c; cin >> r >> c; --r; --c;
obj_r[r].insert(c);
obj_c[c].insert(r);
}
ll Q; cin >> Q;
vc d(Q);
vl l(Q);
rep (i, Q) cin >> d[i] >> l[i];
rep (i, Q) {
char _d = d[i];
ll _l = l[i];
if (_d == 'U') {
ll nx = n_left(obj_c[cs], rs);
if (nx < 0) nx = 0;
else ++nx;
rs = max(nx, rs - _l);
}
if (_d == 'L') {
ll nx = n_left(obj_r[rs], cs);
if (nx < 0) nx = 0;
else ++nx;
cs = max(nx, cs - _l);
}
if (_d == 'D') {
ll nx = n_right(obj_c[cs], rs);
if (nx == INF) nx = H - 1;
else --nx;
rs = min(nx, rs + _l);
}
if (_d == 'R') {
ll nx = n_right(obj_r[rs], cs);
if (nx == INF) nx = W - 1;
else --nx;
cs = min(nx, cs + _l);
}
printf("%lld %lld\n", rs+1, cs+1);
}
}
提出情報
ジャッジ結果
| セット名 |
Sample |
All |
| 得点 / 配点 |
0 / 0 |
0 / 400 |
| 結果 |
|
|
| セット名 |
テストケース |
| 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 |
| ケース名 |
結果 |
実行時間 |
メモリ |
| 000.txt |
AC |
97 ms |
5108 KiB |
| 001.txt |
RE |
106 ms |
3384 KiB |
| 002.txt |
RE |
108 ms |
3404 KiB |
| 003.txt |
RE |
110 ms |
3608 KiB |
| 004.txt |
RE |
109 ms |
3600 KiB |
| 005.txt |
RE |
109 ms |
3496 KiB |
| 006.txt |
RE |
109 ms |
3408 KiB |
| 007.txt |
RE |
107 ms |
3600 KiB |
| 008.txt |
RE |
102 ms |
3288 KiB |
| 009.txt |
RE |
107 ms |
3392 KiB |
| 010.txt |
RE |
107 ms |
3604 KiB |
| 011.txt |
RE |
107 ms |
3288 KiB |
| 012.txt |
RE |
107 ms |
3344 KiB |
| 013.txt |
RE |
107 ms |
3348 KiB |
| 014.txt |
RE |
107 ms |
3380 KiB |
| 015.txt |
RE |
106 ms |
3492 KiB |
| 016.txt |
RE |
106 ms |
3288 KiB |
| 017.txt |
AC |
1787 ms |
23804 KiB |
| 018.txt |
AC |
1451 ms |
23704 KiB |
| 019.txt |
AC |
1289 ms |
23700 KiB |
| 020.txt |
AC |
1191 ms |
23624 KiB |
| 021.txt |
AC |
1103 ms |
23628 KiB |
| 022.txt |
AC |
1047 ms |
23804 KiB |
| 023.txt |
AC |
1014 ms |
23756 KiB |
| 024.txt |
AC |
954 ms |
24060 KiB |
| 025.txt |
AC |
934 ms |
24120 KiB |
| 026.txt |
AC |
893 ms |
24016 KiB |
| example0.txt |
AC |
4 ms |
3736 KiB |
| example1.txt |
AC |
3 ms |
3620 KiB |