結果
| 問題 |
No.326 あみだますたー
|
| コンテスト | |
| ユーザー |
piyoko_212
|
| 提出日時 | 2015-12-20 23:20:36 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 645 bytes |
| コンパイル時間 | 213 ms |
| コンパイル使用メモリ | 35,404 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-09-17 12:25:15 |
| 合計ジャッジ時間 | 3,438 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 2 |
| other | AC * 7 WA * 19 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:12:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
12 | scanf("%d%d",&a,&b);
| ~~~~~^~~~~~~~~~~~~~
main.cpp:14:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
14 | scanf("%d%d",p+i,q+i);
| ~~~~~^~~~~~~~~~~~~~~~
main.cpp:18:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
18 | scanf("%d",r+i);r[i]--;
| ~~~~~^~~~~~~~~~
ソースコード
#include<stdio.h>
#include<algorithm>
using namespace std;
int p[10000];
int q[10000];
int r[10000];
int now[1000];
int s[10000];
int t[10000];
int main(){
int a,b;
scanf("%d%d",&a,&b);
for(int i=0;i<b;i++){
scanf("%d%d",p+i,q+i);
p[i]--;q[i]--;
}
for(int i=0;i<a;i++){
scanf("%d",r+i);r[i]--;
}
for(int i=0;i<a;i++)now[i]=i;
for(int i=0;i<b;i++)swap(now[p[i]],now[q[i]]);
int sz=0;
for(int i=0;i<a-1;i++){
int at=0;
for(int j=0;j<a;j++)if(now[j]==r[i])at=j;
for(int j=at;j>i;j--){
s[sz]=j;
t[sz]=j+1;
swap(now[j],now[j-1]);
sz++;
}
}
printf("%d\n",sz);
for(int i=0;i<sz;i++)printf("%d %d\n",s[i],t[i]);
}
piyoko_212