結果

問題 No.1650 Moving Coins
ユーザー t98slidert98slider
提出日時 2021-08-21 02:31:49
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 616 bytes
コンパイル時間 4,450 ms
コンパイル使用メモリ 168,484 KB
実行使用メモリ 7,148 KB
最終ジャッジ日時 2024-04-22 11:49:32
合計ジャッジ時間 10,950 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
6,816 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 93 ms
6,940 KB
testcase_09 WA -
testcase_10 AC 89 ms
6,944 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 146 ms
7,020 KB
testcase_21 WA -
testcase_22 AC 141 ms
6,940 KB
testcase_23 AC 145 ms
7,016 KB
testcase_24 AC 21 ms
6,940 KB
testcase_25 AC 21 ms
6,940 KB
testcase_26 AC 117 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]==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