Submission #52254754


Source Code Expand

#include <iostream>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <regex>
#include <iomanip>
#include <map>
#include <cassert>
#include <stack>
#include <queue>
using namespace std;
using ll = long long;
// using P = pair<int, int>;
template<class T> using P = pair<T, T>;
using G = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep2(i, n) for (int i = 1; i <= n; i++)
#define rep3(i, n) for (int i = 0; i <= n; i++)
const double PI = acos(-1);
const int MI = 10e8;
const ll MLL = 1e18;
// 4方向
// int di[4] = {1, 0, -1, 0};
// int dj[4] = {0, 1, 0, -1};

// 8方向
const vector<int> di = {-1, -1, 0, 0, 1, 1, 1, -1};
const vector<int> dj = {0, 1, -1, 1, -1, 0, 1, -1};

int main()
{
  /*
    全て目安20m ただ手が動くうちはエンドレスでやる。これによってコンテスト本番の粘りACや思考力のupにつながる
    問題文の理解 read
    実装方針決め plan
    実装 do
    3つのパートに分け、それぞれに時間制限を設けることで以下のメリットがある
     - すぐに解説を見てしまう癖を防止できる
     - 1問に何時間も粘りすぎてしまう問題を防止できる

    解説記事見た article
      理解すること+どうやったらその問題を初見で解けるか考える

      なぜできなかった?
        頭が移動した後のパーツ2〜をそのまま追従する方針だけしか思いつかなかった。
      どうやったらできた?
        

    解説動画見た video
      先頭に値を追加して、末尾を削除するとやりたい機能を実現できる。
  */
  int n,q;
  cin >> n >> q;
  deque<P<int>> d;
  rep(i,n) d.push_back({i+1,0});
  rep(i,q) {
    int type;
    cin >> type;
    if (type == 1){
      char c;
      cin >> c;
      int x = d[0].first;
      int y = d[0].second;
      if (c == 'R') x++;
      if (c == 'L') x--;
      if (c == 'U') y++;
      if (c == 'D') y--;
      d.push_front({x,y});
      d.pop_back();
    }
    else {
      int p;
      cin >> p;
      p--;
      cout << d[p].first << " " << d[p].second << endl; 
    }
  } 
  return 0;
}

Submission Info

Submission Time
Task C - Loong Tracking
User masatofrommgsv
Language C++ 23 (Clang 16.0.6)
Score 300
Code Size 2312 Byte
Status AC
Exec Time 263 ms
Memory 11700 KiB

Compile Error

./Main.cpp:22:11: warning: unused variable 'MI' [-Wunused-const-variable]
const int MI = 10e8;
          ^
./Main.cpp:23:10: warning: unused variable 'MLL' [-Wunused-const-variable]
const ll MLL = 1e18;
         ^
2 warnings generated.

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 1
AC × 31
Set Name Test Cases
Sample sample_01.txt
All 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, random_23.txt, random_24.txt, random_25.txt, random_26.txt, random_27.txt, random_28.txt, random_29.txt, random_30.txt, sample_01.txt
Case Name Status Exec Time Memory
random_01.txt AC 65 ms 11580 KiB
random_02.txt AC 53 ms 3912 KiB
random_03.txt AC 56 ms 11556 KiB
random_04.txt AC 39 ms 7860 KiB
random_05.txt AC 168 ms 11476 KiB
random_06.txt AC 163 ms 10664 KiB
random_07.txt AC 66 ms 11508 KiB
random_08.txt AC 29 ms 5380 KiB
random_09.txt AC 263 ms 11552 KiB
random_10.txt AC 249 ms 6380 KiB
random_11.txt AC 103 ms 11572 KiB
random_12.txt AC 81 ms 6044 KiB
random_13.txt AC 138 ms 3488 KiB
random_14.txt AC 1 ms 3556 KiB
random_15.txt AC 64 ms 11552 KiB
random_16.txt AC 63 ms 11548 KiB
random_17.txt AC 61 ms 11632 KiB
random_18.txt AC 64 ms 11524 KiB
random_19.txt AC 161 ms 11628 KiB
random_20.txt AC 156 ms 11552 KiB
random_21.txt AC 149 ms 11644 KiB
random_22.txt AC 158 ms 11476 KiB
random_23.txt AC 253 ms 11700 KiB
random_24.txt AC 249 ms 11576 KiB
random_25.txt AC 230 ms 11504 KiB
random_26.txt AC 247 ms 11552 KiB
random_27.txt AC 158 ms 11632 KiB
random_28.txt AC 155 ms 11504 KiB
random_29.txt AC 146 ms 11544 KiB
random_30.txt AC 155 ms 11552 KiB
sample_01.txt AC 1 ms 3504 KiB