結果

問題 No.1650 Moving Coins
ユーザー soldraysoldray
提出日時 2021-08-22 02:38:26
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 851 bytes
コンパイル時間 637 ms
コンパイル使用メモリ 121,984 KB
実行使用メモリ 274,248 KB
最終ジャッジ日時 2024-04-23 17:07:39
合計ジャッジ時間 10,513 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 1 ms
6,944 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 300 ms
6,944 KB
testcase_09 TLE -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <iostream>
#include <vector>
#include <stack>

using namespace std;

#define P pair<int, char>

int N;
vector<int> A, B;
vector<P> op;

void dfs(int a) {
  if (A[a] == B[a]) {
    return;
  }

  if (A[a] > B[a]) {
    for (int i = 0; i < A[a] - B[a]; i++) {
      op.push_back(make_pair(a, 'L'));
    }

    return;
  }

  if (a < N - 1) {
    dfs(a + 1);
  }

  for (int i = 0; i < B[a] - A[a]; i++) {
    op.push_back(make_pair(a, 'R'));
  }
}

int main() {
  cin >> N;

  A.resize(N, 0);
  B.resize(N, 0);

  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }

  for (int i = 0; i < N; i++) {
    cin >> B[i];
  }

  for (int i = 0; i < N; i++) {
    dfs(i);
  }

  cout << op.size() << endl;

  for (int i = 0; i < (int)op.size(); i++) {
    cout << (op[i].first + 1) << " " << op[i].second << endl;
  }

  return 0;
}
0