結果

問題 No.429 CupShuffle
ユーザー Naoyk1212Naoyk1212
提出日時 2016-10-03 00:17:09
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 80 ms / 2,000 ms
コード長 962 bytes
コンパイル時間 1,761 ms
コンパイル使用メモリ 149,388 KB
実行使用メモリ 5,348 KB
最終ジャッジ日時 2023-08-13 18:27:33
合計ジャッジ時間 2,673 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,384 KB
testcase_05 AC 1 ms
4,384 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,384 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 8 ms
4,380 KB
testcase_11 AC 79 ms
4,836 KB
testcase_12 AC 75 ms
4,880 KB
testcase_13 AC 80 ms
5,348 KB
testcase_14 AC 78 ms
4,384 KB
testcase_15 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

int main(){
  int n, k, x;
  cin >> n >> k >> x;
  x--;
  int a[n];
  for(int i = 0; i < n; i++){
    a[i] = i + 1;
  }
  
  string str;
  int s, t;
  int tmp;
  for(int i = 0; i < k; i++){
    if(i == x){
      cin >> str >> str;
      break;
    }else{
      cin >> s >> t;
      s--;
      t--;
      tmp = a[s];
      a[s] = a[t];
      a[t] = tmp;
    }
  }

  vector<pair<int, int> > pairs(k - x + 1);
  for(int i = x + 1; i < k; i++){
    cin >> s >> t;
    s--;
    t--;
    pairs.push_back(make_pair(s, t));
  }

  reverse(pairs.begin(), pairs.end());
  
  int c[n];
  for(int i = 0; i < n; i++){
    cin >> c[i];
  }
  
  for(int i = 0; i < pairs.size(); i++){
    tmp = c[pairs[i].first];
    c[pairs[i].first] = c[pairs[i].second];
    c[pairs[i].second] = tmp;
  }
  
  for(int i = 0; i < n; i++){
    if(a[i] == c[i]){
      continue;
    }else{
      cout << i + 1 << " ";
    }
  }
  cout << endl;
} 
0