結果

問題 No.429 CupShuffle
ユーザー notetonousnotetonous
提出日時 2017-08-12 14:21:29
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 917 bytes
コンパイル時間 470 ms
コンパイル使用メモリ 57,072 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-21 06:14:54
合計ジャッジ時間 1,615 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:13:12: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   13 |       scanf(" %c",&s);
      |       ~~~~~^~~~~~~~~~
main.cpp:14:12: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   14 |       scanf(" %c",&t);
      |       ~~~~~^~~~~~~~~~

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
using namespace std;
int N,K,X;
int a[100001],b[100001],c[100001],x[100001];
int main(){
  cin >> N >> K >> X;
  for(int i=1;i<=K;i++){
    if(i==X) {
      char s,t;
      scanf(" %c",&s);
      scanf(" %c",&t);
      //fflush(stdin);
    }
    else cin >> a[i] >> b[i];
  }
  for(int i=1;i<=N;i++)cin >> c[i];
  for(int i=1;i<=N;i++)x[i]=i;

  for(int i=1;i<X;i++){
    int temp=x[a[i]];
    x[a[i]]=x[b[i]];
    x[b[i]]=temp;
  }
  for(int i=K;i>X;i--){
    int temp=c[a[i]];
    c[a[i]]=c[b[i]];
    c[b[i]]=temp;
  }
  for(int i=1;i<=N;i++) cout << x[i] << " " ;
  cout << endl;
  for(int i=1;i<=N;i++) cout << c[i] << " " ;
  cout << endl;
  for(int i=1;i<=N;i++){
    if(x[i]!=c[i]){
      int temp=x[i];
      x[i]=c[i];
      c[i]=temp;
      cout << i ;
      if(i==N)cout << endl;
      else cout << " ";
    }
  }
  return 0;
}
0