結果

問題 No.26 シャッフルゲーム
ユーザー mudbdb
提出日時 2015-07-17 21:09:45
言語 C90
(gcc 12.3.0)
結果
AC  
実行時間 1 ms / 5,000 ms
コード長 437 bytes
コンパイル時間 330 ms
コンパイル使用メモリ 21,504 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-08 08:26:39
合計ジャッジ時間 853 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 10
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:9:3: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    9 |   scanf("%d", &N);
      |   ^~~~~~~~~~~~~~~
main.c:10:3: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   10 |   scanf("%d", &M);
      |   ^~~~~~~~~~~~~~~
main.c:15:5: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   15 |     scanf("%d", &(P[i]));
      |     ^~~~~~~~~~~~~~~~~~~~
main.c:16:5: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   16 |     scanf("%d", &(Q[i]));
      |     ^~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include <stdio.h>
#include <stdlib.h>
int main()
{
  int N;
  int M;
  int *P;
  int *Q;
  scanf("%d", &N);
  scanf("%d", &M);
  P = (int*)malloc(sizeof(int)*M);
  Q = (int*)malloc(sizeof(int)*M);
  int i;
  for (i=0; i<M; i++) {
    scanf("%d", &(P[i]));
    scanf("%d", &(Q[i]));
  }
  for (i=0; i<M; i++) {
    if (N == P[i]) {
      N = Q[i];
    } else if (N == Q[i]) {
      N = P[i];
    }
  }
  printf("%d\n", N);
  return 0;
}
0