結果
問題 |
No.429 CupShuffle
|
ユーザー |
![]() |
提出日時 | 2025-07-07 00:57:55 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 30 ms / 2,000 ms |
コード長 | 931 bytes |
コンパイル時間 | 4,207 ms |
コンパイル使用メモリ | 279,480 KB |
実行使用メモリ | 10,276 KB |
最終ジャッジ日時 | 2025-07-07 00:58:01 |
合計ジャッジ時間 | 5,652 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 16 |
ソースコード
#include <bits/stdc++.h> using namespace std; #ifdef LOCAL #include "settings/debug.cpp" #else #define Debug(...) void(0) #endif #define rep(i, n) for (int i = 0; i < (n); ++i) using ll = long long; using ull = unsigned long long; int main() { cin.tie(nullptr)->sync_with_stdio(false); int n, k, x; cin >> n >> k >> x; vector<int> a(n), b(n); iota(a.begin(), a.end(), 1); vector<pair<string, string>> v(k); rep(i, k) cin >> v[i].first >> v[i].second; rep(i, n) cin >> b[i]; for (int j = 0; j < x - 1; ++j) { auto [s, t] = v[j]; int u = stoi(s), v = stoi(t); swap(a[u - 1], a[v - 1]); } for (int j = k - 1; j >= x; --j) { auto [s, t] = v[j]; int u = stoi(s), v = stoi(t); swap(b[u - 1], b[v - 1]); } vector<int> ans; rep(i, n) { if (a[i] != b[i]) { ans.push_back(i + 1); } } assert(ans.size() == 2); cout << ans[0] << ' ' << ans[1] << '\n'; return 0; }