結果
問題 | No.326 あみだますたー |
ユーザー |
![]() |
提出日時 | 2015-12-25 04:18:00 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 699 bytes |
コンパイル時間 | 409 ms |
コンパイル使用メモリ | 23,168 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-07 23:24:21 |
合計ジャッジ時間 | 1,450 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 26 |
コンパイルメッセージ
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); x--; | ~~~~~^~~~~~~~~~~~~~~~ main.cpp:24:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 24 | scanf("%d", &temp); a[temp - 1] = i; | ~~~~~^~~~~~~~~~~~~
ソースコード
#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); x--;swap(x);}for(i = 0; i < n; i++) {int temp;scanf("%d", &temp); a[temp - 1] = i;}int c = 0;for(i = 0; i < n; i++) {j = t[ a[i] ] - 1;while(i <= j) {ans[c] = j; c++;swap(j);j--;}}printf("%d\n", c);for(i = 0; i < c; i++) { printf("%d %d\n", ans[i] + 1, ans[i] + 2); }return 0;}