結果

問題 No.326 あみだますたー
ユーザー FF256grhyFF256grhy
提出日時 2015-12-25 03:29:43
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 677 bytes
コンパイル時間 139 ms
コンパイル使用メモリ 23,532 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-19 03:29:26
合計ジャッジ時間 4,042 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 1 ms
4,348 KB
testcase_07 AC 1 ms
4,348 KB
testcase_08 AC 1 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:16:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   16 |         scanf("%d%d", &n, &k);
      |         ~~~~~^~~~~~~~~~~~~~~~
main.cpp:19:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   19 |                 scanf("%d%d", &x, &y);
      |                 ~~~~~^~~~~~~~~~~~~~~~
main.cpp:22:39: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   22 |         for(i = 0; i < n; i++) { scanf("%d", &a[i]); a[i]--; }
      |                                  ~~~~~^~~~~~~~~~~~~

ソースコード

diff #

#include <stdio.h>

int n, k, a[100], s[100], t[100], ans[6000];

void swap(int x) {
	int temp = t[ s[x + 1] ];
	t[ s[x + 1] ] = t[ s[x] ];
	t[ s[x] ] = temp;
	temp = s[x + 1];
	s[x + 1] = s[x];
	s[x] = temp;
}

int main(void) {
	int x, y, i, j;
	scanf("%d%d", &n, &k);
	for(i = 0; i < n; i++) { s[i] = t[i] = i; }
	for(i = 0; i < k; i++) {
		scanf("%d%d", &x, &y);
		swap(x - 1);
	}
	for(i = 0; i < n; i++) { scanf("%d", &a[i]); a[i]--; }
	
	int c = 0;
	for(i = 0; i < n; i++) {
		j = t[ a[i] ];
		while(i < j) {
			ans[c] = j - 1; c++;
			swap(j - 1);
			j--;
		}
	}
	
	printf("%d\n", c);
	for(i = 0; i < c; i++) { printf("%d %d\n", ans[i] + 1, ans[i] + 2); }
	
	return 0;
}
0