Submission #1060703
Source Code Expand
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
template<class T> using vv=vector<vector< T > >;
class HashVI { // ハッシュ関数オブジェクト
public:
size_t operator()(const vector<int> &x) const {
const int C = 997; // 素数
size_t t = 0;
for (int i = 0; i != (int)x.size(); ++i) {
t = t * C + x[i];
}
return t;
}
};
struct Point {
int x;
int y;
Point() {};
Point(int x_, int y_) : x(x_), y(y_) {};
};
vi dx = {1, 0, 0, -1};
vi dy = {0, 1, -1, 0};
Point next_point(vi mpj, Point current, int dir) {
Point ret;
if ((int)mpj.size() == 0) {
ret = Point(current.x + dx[dir], current.y + dy[dir]);
} else {
ret = Point(mpj[0], mpj[1]);
}
return ret;
}
int main() {
int k;
scanf("%d", &k);
unordered_map<char, int> ctoi;
ctoi['R'] = 0;
ctoi['U'] = 1;
ctoi['L'] = 3;
ctoi['D'] = 2;
vi s(k);
rep (i, k) {
char tmp;
scanf(" %c", &tmp);
s[i] = ctoi[tmp];
}
unordered_map<vi, vi, HashVI> mp;
Point current(0, 0);
Point prev;
rep (i, k) {
rep (j, 2) {
Point p_j, p_j_;
int j_ = 3 - j;
p_j = next_point(mp[{current.x, current.y, j}], current, j);
p_j_ = next_point(mp[{current.x, current.y, j_}], current, j_);
mp[{p_j.x, p_j.y, j_}] = {p_j_.x, p_j_.y};
mp[{p_j_.x, p_j_.y, j}] = {p_j.x, p_j.y};
}
prev = current;
current = next_point(mp[{current.x, current.y, s[i]}], current, s[i]);
rep (j, 4) {
mp.erase({prev.x, prev.y, j});
}
}
printf("%d %d\n", current.x, current.y);
return 0;
}
Submission Info
Submission Time |
|
Task |
C - 幼稚園児高橋君 |
User |
tspcx |
Language |
C++14 (Clang++ 3.4) |
Score |
100 |
Code Size |
2462 Byte |
Status |
AC |
Exec Time |
453 ms |
Memory |
61932 KB |
Judge Result
Set Name |
Sample |
Subtask1 |
Score / Max Score |
0 / 0 |
100 / 100 |
Status |
|
|
Set Name |
Test Cases |
Sample |
subtask0_sample_01.txt, subtask0_sample_02.txt, subtask0_sample_03.txt |
Subtask1 |
subtask0_sample_01.txt, subtask0_sample_02.txt, subtask0_sample_03.txt, subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask1_13.txt, subtask1_14.txt, subtask1_15.txt, subtask1_16.txt, subtask1_17.txt, subtask1_18.txt, subtask1_19.txt, subtask1_20.txt, subtask1_21.txt |
Case Name |
Status |
Exec Time |
Memory |
subtask0_sample_01.txt |
AC |
20 ms |
840 KB |
subtask0_sample_02.txt |
AC |
18 ms |
928 KB |
subtask0_sample_03.txt |
AC |
17 ms |
928 KB |
subtask1_01.txt |
AC |
17 ms |
924 KB |
subtask1_02.txt |
AC |
17 ms |
924 KB |
subtask1_03.txt |
AC |
17 ms |
928 KB |
subtask1_04.txt |
AC |
19 ms |
928 KB |
subtask1_05.txt |
AC |
17 ms |
800 KB |
subtask1_06.txt |
AC |
17 ms |
924 KB |
subtask1_07.txt |
AC |
339 ms |
12876 KB |
subtask1_08.txt |
AC |
337 ms |
12824 KB |
subtask1_09.txt |
AC |
336 ms |
10496 KB |
subtask1_10.txt |
AC |
334 ms |
14612 KB |
subtask1_11.txt |
AC |
331 ms |
11792 KB |
subtask1_12.txt |
AC |
330 ms |
10536 KB |
subtask1_13.txt |
AC |
330 ms |
12432 KB |
subtask1_14.txt |
AC |
431 ms |
61864 KB |
subtask1_15.txt |
AC |
437 ms |
61932 KB |
subtask1_16.txt |
AC |
355 ms |
31668 KB |
subtask1_17.txt |
AC |
453 ms |
61920 KB |
subtask1_18.txt |
AC |
431 ms |
61920 KB |
subtask1_19.txt |
AC |
354 ms |
34480 KB |
subtask1_20.txt |
AC |
344 ms |
33132 KB |
subtask1_21.txt |
AC |
364 ms |
31672 KB |