結果
| 問題 |
No.1650 Moving Coins
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-08-24 18:56:35 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 163 ms / 2,000 ms |
| コード長 | 878 bytes |
| コンパイル時間 | 1,075 ms |
| コンパイル使用メモリ | 79,416 KB |
| 実行使用メモリ | 8,040 KB |
| 最終ジャッジ日時 | 2024-11-15 06:49:27 |
| 合計ジャッジ時間 | 7,326 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 24 |
コンパイルメッセージ
main.cpp:8:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
8 | main()
| ^~~~
ソースコード
#include<iostream>
#include<vector>
#include<queue>
using namespace std;
int N,A[2<<17],B[2<<17];
vector<pair<int,bool> >E;
bool vis[2<<17];
main()
{
cin>>N;
for(int i=0;i<N;i++)cin>>A[i];
for(int i=0;i<N;i++)cin>>B[i];
queue<int>P;
for(int i=0;i<N;i++)
{
if(A[i]<=B[i])
{
if(i+1==N||A[i+1]>B[i])P.push(i),vis[i]=true;
}
else
{
if(i==0||A[i-1]<B[i])P.push(i),vis[i]=true;
}
}
while(!P.empty())
{
int id=P.front();P.pop();
for(;A[id]>B[id];A[id]--)E.push_back(make_pair(id+1,false));
for(;A[id]<B[id];A[id]++)E.push_back(make_pair(id+1,true));
for(int t=id-1;t<=id+1;t+=2)if(0<=t&&t<N&&!vis[t])
{
if(A[t]<=B[t])
{
if(t+1==N||A[t+1]>B[t])P.push(t),vis[t]=true;
}
else
{
if(t==0||A[t-1]<B[t])P.push(t),vis[t]=true;
}
}
}
cout<<E.size()<<endl;
for(pair<int,bool>p:E)cout<<p.first<<" "<<(p.second?'R':'L')<<"\n";
}