結果
| 問題 | No.429 CupShuffle | 
| コンテスト | |
| ユーザー |  alpha_virginis | 
| 提出日時 | 2016-11-09 20:16:04 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 32 ms / 2,000 ms | 
| コード長 | 869 bytes | 
| コンパイル時間 | 1,420 ms | 
| コンパイル使用メモリ | 168,704 KB | 
| 実行使用メモリ | 6,820 KB | 
| 最終ジャッジ日時 | 2024-11-25 05:56:26 | 
| 合計ジャッジ時間 | 2,270 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 16 | 
ソースコード
#include <bits/stdc++.h>
int n, k, x;
int zss[112345][2];
int xs[112345];
int ys[112345];
int main() {
  scanf("%d %d %d\n", &n, &k, &x);
  for(int i = 0; i < k; ++i) {
    if( i + 1 == x ) {
      char buf[256];
      fgets(buf, sizeof(buf), stdin);
      continue;
    }
    scanf("%d %d\n", &zss[i][0], &zss[i][1]);
  }
  for(int i = 1; i <= n; ++i) {
    scanf("%d", &ys[i]);
  }
  // step 1
  for(int i = 1; i <= n; ++i) {
    xs[i] = i;
  }
  // step 2 : x' <- Ax
  for(int i = 0; i < x; ++i) {
    std::swap(xs[zss[i][0]], xs[zss[i][1]]);
  }
  // step 3 : y' <- B^ty
  for(int i = k - 1; i >= x; --i) {
    std::swap(ys[zss[i][0]], ys[zss[i][1]]);
  }
  // step 4
  std::vector<int> res;
  for(int i = 1; i <= n; ++i) {
    if( xs[i] != ys[i] ) res.push_back(i);
  }
  assert( 2 == (int)res.size() );
  printf("%d %d\n", res[0], res[1]);
  
  return 0;
}
            
            
            
        