Submission #73584554
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
#define double long double
using ll = long long;
using ull = unsigned long long;
using VB = vector<bool>;
using VVB = vector<VB>;
using VVVB = vector<VVB>;
using VC = vector<char>;
using VVC = vector<VC>;
using VI = vector<int>;
using VVI = vector<VI>;
using VVVI = vector<VVI>;
using VVVVI = vector<VVVI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using VVVL = vector<VVL>;
using VVVVL = vector<VVVL>;
using VVVVVL = vector<VVVVL>;
using VD = vector<double>;
using VVD = vector<VD>;
using VVVD = vector<VVD>;
using VT = vector<string>;
using VVT = vector<VT>;
//using P = pair<int, int>;
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for (ll i = a; i < (ll)(b); i++)
#define ALL(a) (a).begin(),(a).end()
constexpr int INF = 1001001001;
constexpr ll LINF = 1001001001001001001ll;
//constexpr ll LINF = 8e18;
//constexpr int DX[] = {-1, -1, 0, 0, 1, 1};
//constexpr int DY[] = {-1, 0, -1, 1, 0, 1};
constexpr int DX[] = {1, 0, -1, 0, 0, 0};
constexpr int DY[] = {0, 1, 0, -1, 0, 0};
constexpr int DZ[] = {0, 0, 0, 0, 1, -1};
template< typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true); }
template< typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true); }
const ll MOD = 998244353;
//const ll MOD = 1000000007;
int main() {
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int n, q;
cin >> n;
VI a(n + 2, 0);
REP(i, n) cin >> a[i + 1];
a[n + 1] = INF;
cin >> q;
VI w(q), x(q), y(q);
REP(i, q) {
cin >> w[i] >> x[i];
if (w[i] == 1) cin >> y[i];
}
map<int, int> f, b;
b[0] = a[1];
f[INF] = a[n];
REP(i, n) {
f[a[i + 1]] = a[i];
b[a[i + 1]] = a[i + 2];
}
REP(i, q) {
//cout << "i=" << i << endl;
if (w[i] == 1) {
int z = b[x[i]];
b[x[i]] = y[i];
f[y[i]] = x[i];
b[y[i]] = z;
f[z] = y[i];
} else {
int fx = f[x[i]];
int bx = b[x[i]];
b[fx] = bx;
f[bx] = fx;
}
}
VI ans(0);
int z = b[0];
while (z != INF) {
//cout << "z=" << z << endl;
ans.push_back(z);
z = b[z];
}
REP(i, ans.size()) {
if (i) cout << " ";
cout << ans[i];
}
cout << endl;
}
Submission Info
| Submission Time |
|
| Task |
H - Insert or Erase |
| User |
ktr216 |
| Language |
C++23 (GCC 15.2.0) |
| Score |
475 |
| Code Size |
2503 Byte |
| Status |
AC |
| Exec Time |
732 ms |
| Memory |
46320 KiB |
Judge Result
| Set Name |
Sample |
All |
| Score / Max Score |
0 / 0 |
475 / 475 |
| Status |
|
|
| Set Name |
Test Cases |
| Sample |
sample_01.txt, sample_02.txt |
| All |
min.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, sample_01.txt, sample_02.txt |
| Case Name |
Status |
Exec Time |
Memory |
| min.txt |
AC |
1 ms |
3588 KiB |
| random_01.txt |
AC |
732 ms |
45568 KiB |
| random_02.txt |
AC |
486 ms |
31392 KiB |
| random_03.txt |
AC |
505 ms |
36804 KiB |
| random_04.txt |
AC |
167 ms |
15260 KiB |
| random_05.txt |
AC |
579 ms |
35828 KiB |
| random_06.txt |
AC |
374 ms |
23636 KiB |
| random_07.txt |
AC |
506 ms |
33324 KiB |
| random_08.txt |
AC |
191 ms |
17424 KiB |
| random_09.txt |
AC |
421 ms |
26324 KiB |
| random_10.txt |
AC |
219 ms |
19228 KiB |
| random_11.txt |
AC |
386 ms |
25812 KiB |
| random_12.txt |
AC |
44 ms |
8148 KiB |
| random_13.txt |
AC |
622 ms |
45808 KiB |
| random_14.txt |
AC |
428 ms |
35856 KiB |
| random_15.txt |
AC |
313 ms |
26324 KiB |
| random_16.txt |
AC |
621 ms |
45804 KiB |
| random_17.txt |
AC |
439 ms |
35792 KiB |
| random_18.txt |
AC |
317 ms |
26324 KiB |
| random_19.txt |
AC |
158 ms |
25428 KiB |
| random_20.txt |
AC |
281 ms |
46320 KiB |
| random_21.txt |
AC |
162 ms |
25116 KiB |
| sample_01.txt |
AC |
1 ms |
3612 KiB |
| sample_02.txt |
AC |
1 ms |
3612 KiB |