結果
| 問題 |
No.326 あみだますたー
|
| コンテスト | |
| ユーザー |
FF256grhy
|
| 提出日時 | 2015-12-25 03:57:40 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 675 bytes |
| コンパイル時間 | 173 ms |
| コンパイル使用メモリ | 23,296 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-09-18 23:42:59 |
| 合計ジャッジ時間 | 3,886 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 2 |
| other | AC * 7 WA * 19 |
コンパイルメッセージ
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: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]--; }
| ~~~~~^~~~~~~~~~~~~
ソースコード
#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++) { scanf("%d", &a[i]); a[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;
}
FF256grhy