結果

問題 No.429 CupShuffle
コンテスト
ユーザー Naoyk1212
提出日時 2016-10-03 00:17:09
言語 C++11
(gcc 15.3.0 + boost 1.92.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 50 ms / 2,000 ms
+ 869µs
コード長 962 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 861 ms
コンパイル使用メモリ 185,432 KB
実行使用メモリ 9,916 KB
最終ジャッジ日時 2026-09-27 14:21:24
合計ジャッジ時間 2,983 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge4_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 16
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#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