Submission #1060702
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);
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};
}
current = next_point(mp[{current.x, current.y, s[i]}], current, s[i]);
}
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 |
2363 Byte |
Status |
AC |
Exec Time |
935 ms |
Memory |
168388 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 |
18 ms |
928 KB |
subtask0_sample_02.txt |
AC |
19 ms |
928 KB |
subtask0_sample_03.txt |
AC |
17 ms |
928 KB |
subtask1_01.txt |
AC |
18 ms |
924 KB |
subtask1_02.txt |
AC |
17 ms |
924 KB |
subtask1_03.txt |
AC |
17 ms |
920 KB |
subtask1_04.txt |
AC |
17 ms |
928 KB |
subtask1_05.txt |
AC |
17 ms |
924 KB |
subtask1_06.txt |
AC |
17 ms |
928 KB |
subtask1_07.txt |
AC |
601 ms |
118960 KB |
subtask1_08.txt |
AC |
594 ms |
118916 KB |
subtask1_09.txt |
AC |
591 ms |
117372 KB |
subtask1_10.txt |
AC |
604 ms |
120452 KB |
subtask1_11.txt |
AC |
559 ms |
118016 KB |
subtask1_12.txt |
AC |
594 ms |
117248 KB |
subtask1_13.txt |
AC |
588 ms |
118528 KB |
subtask1_14.txt |
AC |
717 ms |
168384 KB |
subtask1_15.txt |
AC |
827 ms |
168384 KB |
subtask1_16.txt |
AC |
658 ms |
134912 KB |
subtask1_17.txt |
AC |
935 ms |
168388 KB |
subtask1_18.txt |
AC |
884 ms |
168388 KB |
subtask1_19.txt |
AC |
638 ms |
137348 KB |
subtask1_20.txt |
AC |
593 ms |
136064 KB |
subtask1_21.txt |
AC |
618 ms |
134828 KB |