結果
問題 | No.429 CupShuffle |
ユーザー |
|
提出日時 | 2016-10-02 22:52:31 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 87 ms / 2,000 ms |
コード長 | 741 bytes |
コンパイル時間 | 1,049 ms |
コンパイル使用メモリ | 73,856 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-21 13:24:48 |
合計ジャッジ時間 | 2,161 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 16 |
ソースコード
#include <iostream>#include <cstdio>#include <vector>#include <algorithm>#include <utility>#include <string>using namespace std;int main() {int n, k, x;cin >> n >> k >> x;vector<int> a(k+1, -1), b(k+1, -1);vector<int> c(n), d(n);for (int i = 1; i <= k; i++) {if (i == x) {string tmp;cin >> tmp >> tmp;continue;}cin >> a[i] >> b[i];a[i]--;b[i]--;}for (int i = 0; i < n; i++) {d[i] = i + 1;cin >> c[i];}for (int i = 1; i < x; i++) {swap(d[a[i]], d[b[i]]);}for (int i = k; i > x; i--) {swap(c[a[i]], c[b[i]]);}vector<int> ans;for (int i = 0; i < n; i++) {if (c[i] != d[i]) {ans.push_back(i+1);}}cout << ans[0] << " " << ans[1] << endl;return 0;}