結果

問題 No.1650 Moving Coins
ユーザー carrot46carrot46
提出日時 2021-08-20 21:46:49
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 281 ms / 2,000 ms
コード長 1,668 bytes
コンパイル時間 2,283 ms
コンパイル使用メモリ 203,168 KB
実行使用メモリ 17,976 KB
最終ジャッジ日時 2024-04-22 04:11:33
合計ジャッジ時間 11,528 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 240 ms
5,376 KB
testcase_04 AC 172 ms
5,376 KB
testcase_05 AC 208 ms
5,472 KB
testcase_06 AC 236 ms
5,472 KB
testcase_07 AC 246 ms
5,376 KB
testcase_08 AC 257 ms
7,140 KB
testcase_09 AC 268 ms
6,956 KB
testcase_10 AC 263 ms
7,204 KB
testcase_11 AC 258 ms
7,236 KB
testcase_12 AC 262 ms
6,340 KB
testcase_13 AC 259 ms
6,496 KB
testcase_14 AC 266 ms
6,884 KB
testcase_15 AC 260 ms
6,100 KB
testcase_16 AC 270 ms
7,376 KB
testcase_17 AC 256 ms
7,300 KB
testcase_18 AC 277 ms
7,436 KB
testcase_19 AC 281 ms
17,976 KB
testcase_20 AC 277 ms
8,476 KB
testcase_21 AC 280 ms
13,288 KB
testcase_22 AC 277 ms
8,476 KB
testcase_23 AC 280 ms
8,532 KB
testcase_24 AC 232 ms
5,376 KB
testcase_25 AC 239 ms
5,376 KB
testcase_26 AC 41 ms
6,400 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/modint>
using namespace std;
using namespace atcoder;
//#pragma GCC optimize("Ofast")
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()

using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;

ll N,M,H,W,Q,K,A,B;
string S;
using P = pair<ll, ll>;
using tp = tuple<ll, ll, ll>;
const ll INF = (1LL<<60);

template<class T> bool chmin(T &a, const T b){
    if(a > b) {a = b; return true;}
    else return false;
}
template<class T> bool chmax(T &a, const T b){
    if(a < b) {a = b; return true;}
    else return false;
}
template<class T> void my_printv(std::vector<T> v,bool endline = true){
    if(!v.empty()){
        for(std::size_t i{}; i<v.size()-1; ++i) std::cout<<v[i]<<" ";
        std::cout<<v.back();
    }
    if(endline) std::cout<<std::endl;
}

using mint = modint998244353;
using vm = vector<mint>;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin>>N;
    vec a(N), b(N);
    rep(i, N) cin>>a[i];
    rep(i, N) cin>>b[i];
    vector<pair<int, char>> ans;
    auto dfs = [&](auto &&self, int i) -> void{
        if(i == N) return;
        if(a[i] < b[i]) self(self, i + 1);
        while(a[i] != b[i]){
            if(a[i] < b[i]){
                ans.emplace_back(i, 'R');
                ++a[i];
            }else{
                ans.emplace_back(i, 'L');
                --a[i];
            }
        }
    };
    rep(i, N) dfs(dfs, i);
    cout<<size(ans)<<endl;
    for(auto [i, c] : ans) cout<<i + 1<<' '<<c<<endl;
}
0