Submission #63282699
Source Code Expand
Copy
#include <bits/stdc++.h>#define dbg(x) cout << #x << '=' << x << endl#define rep(i, l, r) for (int i = (l); i <= (r); i++)#define frep(i, r, l) for (int i = (r); i >= (l); i--)using namespace std;const int N = 1e6 + 10;int n, q;int x[N], p[N], now[N];void work() {cin >> n >> q;rep(i, 1, n) x[i] = i, p[i] = i, now[i] = p[i];while (q--) {int op, a, b;cin >> op >> a;if (op == 3) {cout << p[x[a]] << "\n";}if (op == 1) {
#include <bits/stdc++.h> #define dbg(x) cout << #x << '=' << x << endl #define rep(i, l, r) for (int i = (l); i <= (r); i++) #define frep(i, r, l) for (int i = (r); i >= (l); i--) using namespace std; const int N = 1e6 + 10; int n, q; int x[N], p[N], now[N]; void work() { cin >> n >> q; rep(i, 1, n) x[i] = i, p[i] = i, now[i] = p[i]; while (q--) { int op, a, b; cin >> op >> a; if (op == 3) { cout << p[x[a]] << "\n"; } if (op == 1) { cin >> b; x[a] = now[b]; } if (op == 2) { cin >> b; int x = now[a], y = now[b]; swap(p[x], p[y]); swap(now[a], now[b]); } } } int main() { std::ios::sync_with_stdio(false); cin.tie(0), cout.tie(0); int T = 1, opinput = 0; if (opinput) cin >> T; while (T--) work(); return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - Pigeon Swap |
User | cyt_before |
Language | C++ 20 (gcc 12.2) |
Score | 350 |
Code Size | 807 Byte |
Status | AC |
Exec Time | 108 ms |
Memory | 15356 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 350 / 350 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt |
All | 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt, 01_random_19.txt, 01_random_20.txt, 01_random_21.txt, 01_random_22.txt, 01_random_23.txt, 01_random_24.txt, 01_random_25.txt, 01_random_26.txt, 01_random_27.txt, 01_random_28.txt, 01_random_29.txt, 01_random_30.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
00_sample_00.txt | AC | 1 ms | 3436 KB |
00_sample_01.txt | AC | 1 ms | 3512 KB |
00_sample_02.txt | AC | 1 ms | 3604 KB |
01_random_03.txt | AC | 108 ms | 15192 KB |
01_random_04.txt | AC | 108 ms | 15316 KB |
01_random_05.txt | AC | 107 ms | 15236 KB |
01_random_06.txt | AC | 108 ms | 15232 KB |
01_random_07.txt | AC | 8 ms | 11036 KB |
01_random_08.txt | AC | 59 ms | 11060 KB |
01_random_09.txt | AC | 50 ms | 15228 KB |
01_random_10.txt | AC | 55 ms | 15316 KB |
01_random_11.txt | AC | 66 ms | 15232 KB |
01_random_12.txt | AC | 39 ms | 15164 KB |
01_random_13.txt | AC | 79 ms | 15104 KB |
01_random_14.txt | AC | 56 ms | 15232 KB |
01_random_15.txt | AC | 38 ms | 15300 KB |
01_random_16.txt | AC | 82 ms | 15168 KB |
01_random_17.txt | AC | 72 ms | 15232 KB |
01_random_18.txt | AC | 42 ms | 15132 KB |
01_random_19.txt | AC | 60 ms | 15108 KB |
01_random_20.txt | AC | 50 ms | 15240 KB |
01_random_21.txt | AC | 41 ms | 15348 KB |
01_random_22.txt | AC | 71 ms | 15124 KB |
01_random_23.txt | AC | 90 ms | 15356 KB |
01_random_24.txt | AC | 82 ms | 15232 KB |
01_random_25.txt | AC | 100 ms | 15232 KB |
01_random_26.txt | AC | 99 ms | 15176 KB |
01_random_27.txt | AC | 99 ms | 15236 KB |
01_random_28.txt | AC | 107 ms | 15228 KB |
01_random_29.txt | AC | 100 ms | 15352 KB |
01_random_30.txt | AC | 30 ms | 3448 KB |