結果

問題 No.1650 Moving Coins
ユーザー t98slidert98slider
提出日時 2021-08-21 02:32:21
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 152 ms / 2,000 ms
コード長 618 bytes
コンパイル時間 3,101 ms
コンパイル使用メモリ 169,432 KB
実行使用メモリ 22,512 KB
最終ジャッジ日時 2024-04-22 11:50:27
合計ジャッジ時間 7,813 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 22 ms
6,944 KB
testcase_04 AC 17 ms
6,944 KB
testcase_05 AC 21 ms
6,940 KB
testcase_06 AC 21 ms
6,944 KB
testcase_07 AC 21 ms
6,944 KB
testcase_08 AC 86 ms
6,940 KB
testcase_09 AC 88 ms
6,944 KB
testcase_10 AC 89 ms
6,944 KB
testcase_11 AC 94 ms
6,940 KB
testcase_12 AC 63 ms
6,940 KB
testcase_13 AC 64 ms
6,940 KB
testcase_14 AC 85 ms
6,940 KB
testcase_15 AC 53 ms
6,940 KB
testcase_16 AC 96 ms
6,940 KB
testcase_17 AC 101 ms
6,940 KB
testcase_18 AC 110 ms
6,940 KB
testcase_19 AC 148 ms
22,512 KB
testcase_20 AC 140 ms
7,016 KB
testcase_21 AC 152 ms
14,700 KB
testcase_22 AC 140 ms
7,020 KB
testcase_23 AC 141 ms
7,020 KB
testcase_24 AC 20 ms
6,944 KB
testcase_25 AC 21 ms
6,940 KB
testcase_26 AC 120 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

int main(){
    int n;
    cin>>n;
    vector<int> a(n),b(n);
    vector<pair<int,char>> ans;
    for(auto &&v:a)cin>>v;
    for(auto &&v:b)cin>>v;
    function<void(int)> dfs=[&](int i){
        while(b[i]>a[i]){
            if(i+1<n&&a[i]+1==a[i+1])dfs(i+1);
            a[i]++;
            ans.emplace_back(i+1,'R');
        }
        while(a[i]>b[i]){
            a[i]--;
            ans.emplace_back(i+1,'L');
        }
    };
    for(int i=0;i<n;i++)dfs(i);
    cout<<ans.size()<<'\n';
    for(int i=0;i<ans.size();i++)cout<<ans[i].first<<' '<<ans[i].second<<'\n';
}
0