結果

問題 No.26 シャッフルゲーム
コンテスト
ユーザー satanic
提出日時 2015-11-23 19:18:46
言語 C90(gcc12)
(gcc 12.4.0)
コンパイル:
gcc-12 -O2 -std=c90 -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
AC  
実行時間 0 ms / 5,000 ms
+ 705µs
コード長 344 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 44 ms
コンパイル使用メモリ 28,800 KB
実行使用メモリ 5,888 KB
最終ジャッジ日時 2026-07-24 04:28:27
合計ジャッジ時間 1,378 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
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%d", &n, &m);
      |   ^~~~~~~~~~~~~~~~~~~~~
main.c:12:5: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   12 |     scanf("%d%d", &p, &q);
      |     ^~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #
raw source code

#include <stdio.h>

int main(){
  int cup[3]={0};
  int n, m, p, q;
  int tmp;
  int i;

  scanf("%d%d", &n, &m);
  cup[n-1]=1;
  for(i=0; i<m; ++i){
    scanf("%d%d", &p, &q);
    tmp=cup[p-1];
    cup[p-1]=cup[q-1];
    cup[q-1]=tmp;
  }
  for(i=0; i<3; ++i){
    if(cup[i]==1){
      printf("%d\n", i+1);
      break;
    }
  }
  return 0;
}
0