結果

問題 No.429 CupShuffle
ユーザー DugongDugong
提出日時 2016-10-04 20:21:55
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 31 ms / 2,000 ms
コード長 812 bytes
コンパイル時間 187 ms
コンパイル使用メモリ 24,832 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-01 12:26:07
合計ジャッジ時間 1,470 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 0 ms
5,376 KB
testcase_02 AC 0 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 0 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 4 ms
5,376 KB
testcase_11 AC 31 ms
5,376 KB
testcase_12 AC 30 ms
5,376 KB
testcase_13 AC 31 ms
5,376 KB
testcase_14 AC 31 ms
5,376 KB
testcase_15 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:6:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    6 |   scanf("%d %d %d",&n,&k,&X);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~
main.cpp:11:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   11 |     scanf("%d %d",&a,&b);
      |     ~~~~~^~~~~~~~~~~~~~~
main.cpp:19:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   19 |   scanf("%s %s",dummy,dummy+4);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
main.cpp:23:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   23 |     scanf("%d %d",&p,&q);
      |     ~~~~~^~~~~~~~~~~~~~~
main.cpp:31:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   31 |     scanf("%d",c+i);
      |     ~~~~~^~~~~~~~~~

ソースコード

diff #

#include<cstdio>
#include<cstring>

int main(){
  int n,k,X;
  scanf("%d %d %d",&n,&k,&X);
  int x[n];
  for(int i=0;i<n;i++) x[i] = i;
  for(int i=0;i<X-1;i++){
    int a,b;
    scanf("%d %d",&a,&b);
    a--;
    b--;
    int t = x[a];
    x[a] = x[b];
    x[b] = t;
  }
  char dummy[20];
  scanf("%s %s",dummy,dummy+4);
  int a[k],b[k];
  for(int i=0;i<k-X;i++){
    int p,q;
    scanf("%d %d",&p,&q);
    p--;
    q--;
    a[i] = p;
    b[i] = q;
  }
  int c[n];
  for(int i=0;i<n;i++){
    scanf("%d",c+i);
    c[i]--;
  }
  for(int i=k-X-1;i>=0;i--){
    int t = c[a[i]];
    c[a[i]] = c[b[i]];
    c[b[i]] = t;
  }
  bool flag = false;
  for(int i=0;i<n;i++){
    if(c[i]!=x[i]){
      if(!flag){
        printf("%d ",i+1);
        flag = true;
      }else{
        printf("%d\n",i+1);
      }
    }
  }
}
0