Submission #1060692


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 <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 > >;

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);
  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];
  }
  map<vi, vi> 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_}].clear();
      mp[{p_j.x, p_j.y, j_}] = {p_j_.x, p_j_.y};
      mp[{p_j_.x, p_j_.y, j}].clear();
      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 2107 Byte
Status AC
Exec Time 1164 ms
Memory 170280 KB

Judge Result

Set Name Sample Subtask1
Score / Max Score 0 / 0 100 / 100
Status
AC × 3
AC × 24
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 932 KB
subtask0_sample_02.txt AC 17 ms 800 KB
subtask0_sample_03.txt AC 16 ms 928 KB
subtask1_01.txt AC 19 ms 792 KB
subtask1_02.txt AC 17 ms 804 KB
subtask1_03.txt AC 18 ms 796 KB
subtask1_04.txt AC 19 ms 840 KB
subtask1_05.txt AC 19 ms 920 KB
subtask1_06.txt AC 19 ms 800 KB
subtask1_07.txt AC 841 ms 124276 KB
subtask1_08.txt AC 837 ms 124188 KB
subtask1_09.txt AC 839 ms 122484 KB
subtask1_10.txt AC 825 ms 125988 KB
subtask1_11.txt AC 839 ms 123168 KB
subtask1_12.txt AC 848 ms 122404 KB
subtask1_13.txt AC 840 ms 123820 KB
subtask1_14.txt AC 1164 ms 170272 KB
subtask1_15.txt AC 1055 ms 170272 KB
subtask1_16.txt AC 932 ms 142108 KB
subtask1_17.txt AC 791 ms 170228 KB
subtask1_18.txt AC 1148 ms 170280 KB
subtask1_19.txt AC 808 ms 144932 KB
subtask1_20.txt AC 772 ms 143520 KB
subtask1_21.txt AC 1081 ms 142124 KB