結果

問題 No.326 あみだますたー
ユーザー piyoko_212piyoko_212
提出日時 2015-12-20 23:20:36
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 645 bytes
コンパイル時間 1,076 ms
コンパイル使用メモリ 35,568 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-17 14:37:49
合計ジャッジ時間 5,161 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 1 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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]--;
      |                 ~~~~~^~~~~~~~~~

ソースコード

diff #

#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]);
}
0