結果
| 問題 |
No.326 あみだますたー
|
| コンテスト | |
| ユーザー |
kongarishisyamo
|
| 提出日時 | 2016-03-17 13:21:30 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 625 bytes |
| コンパイル時間 | 528 ms |
| コンパイル使用メモリ | 61,348 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-10-01 08:50:42 |
| 合計ジャッジ時間 | 3,933 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 8 WA * 18 |
ソースコード
#include<iostream>
#include<vector>
using namespace std;
vector<int> L;
vector<int> R;
int amida_to(int n){
for(int i=0;i<L.size();i++){
if(L[i]==n) n=R[i];
else if(R[i]==n) n=L[i];
}
return n;
}
int main(){
int N,K,X,Y,A;
cin>>N;
cin>>K;
for(int i=0;i<K;i++){
cin>>X>>Y;
L.push_back(X);
R.push_back(Y);
}
for(int i=0;i<N;i++){
cin>>A;
int to=amida_to(i+1);
while(to>A){
L.push_back(to-1);
R.push_back(to);
to--;
}
while(to<A){
L.push_back(to);
R.push_back(to+1);
to++;
}
}
cout<<L.size()-K<<endl;
for(int i=K;i<L.size();i++){
cout<<L[i]<<" "<<R[i]<<endl;
}
}
kongarishisyamo