結果
問題 | No.429 CupShuffle |
ユーザー |
|
提出日時 | 2016-10-02 23:22:22 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 31 ms / 2,000 ms |
コード長 | 932 bytes |
コンパイル時間 | 1,846 ms |
コンパイル使用メモリ | 174,072 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-21 13:35:37 |
合計ジャッジ時間 | 2,564 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 16 |
ソースコード
#include <bits/stdc++.h>using namespace std;typedef pair<int, int> P;int main() {cin.tie(0);ios::sync_with_stdio(false);int n, k, x;cin >> n >> k >> x;vector<int> a(n);for (int i = 0; i < n; i++) a[i] = i + 1;for (int i = 0; i < x - 1; i++) {int p, q;cin >> p >> q;p--;q--;swap(a[p], a[q]);}char ax, bx;cin >> ax >> bx;vector<P> memo;for (int i = x; i < k; i++) {int p, q;cin >> p >> q;p--;q--;memo.emplace_back(p, q);}vector<int> b(n);for (int i = 0; i < n; i++) cin >> b[i];for (auto i = memo.rbegin(), e = memo.rend(); i != e; ++i) {swap(b[i->first], b[i->second]);}vector<int> ans;for (int i = 0; i < n; i++) {if (a[i] != b[i]) ans.emplace_back(i + 1);}cout << ans[0] << " " << ans[1] << "\n";return 0;}