結果

問題 No.1650 Moving Coins
ユーザー 沙耶花
提出日時 2021-08-20 21:44:03
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 277 ms / 2,000 ms
コード長 825 bytes
コンパイル時間 3,814 ms
コンパイル使用メモリ 253,268 KB
最終ジャッジ日時 2025-01-23 23:07:31
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 24
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:37:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   37 |                 scanf("%d",&A[i]);
      |                 ~~~~~^~~~~~~~~~~~
main.cpp:40:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   40 |                 scanf("%d",&B[i]);
      |                 ~~~~~^~~~~~~~~~~~

ソースコード

diff #

#include <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using mint = modint998244353;
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf 1000000001

vector<int> A,B;
int N;
vector<pair<int,char>> ans;
void Right(int ind){
	A[ind]++;
	if(ind!=N-1&&A[ind]==A[ind+1]){
		Right(ind+1);
	}
	ans.emplace_back(ind+1,'R');
}

void Left(int ind){
	A[ind]--;
	if(ind!=0&&A[ind]==A[ind-1]){
		Right(ind-1);
	}
	ans.emplace_back(ind+1,'L');
}

int main(){
	
	
	cin>>N;
	
	A.resize(N);
	B.resize(N);
	rep(i,N){
		scanf("%d",&A[i]);
	}
	rep(i,N){
		scanf("%d",&B[i]);
	}
	
	rep(i,N){
		while(A[i]<B[i]){
			Right(i);
		}
		while(A[i]>B[i]){
			Left(i);
		}
	}
	
	cout<<ans.size()<<endl;
	
	rep(i,ans.size()){
		cout<<ans[i].first<<' '<<ans[i].second<<endl;
	}
	
	return 0;
}
0