造福后人,虽然我仍然 wrong answer on test 23。
gen:
#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
mt19937 rng(time(NULL));
int n = 20, q = 20;
int fa[N];
int main() {
cout << n << " " << q << endl;
for (int i = 2; i <= n; i++) {
fa[i] = rng() % (i - 1) + 1;
if (rng() % 2) {
cout << i << " " << fa[i] << endl;
} else {
cout << fa[i] << " " << i << endl;
}
}
vector<pair<int, int> > path;
for (int i = 1; i <= q; i++) {
int opt = rng() % 4;
while (opt > 1 && path.empty()) { opt = rng() % 4; }
if (opt == 0) { opt = 1; }
cout << opt << " ";
if (opt == 1) {
int x = rng() % n + 1, y = rng() % n + 1;
if (x > y) { swap(x, y); }
cout << x << " " << y << endl;
path.push_back(make_pair(x, y));
} else if (opt == 2) {
swap(path[rng() % path.size()], path[path.size() - 1]);
cout << path.back().first << " " << path.back().second << endl;
path.pop_back();
} else {
int d = rng() % 2;
cout << d << endl;
}
}
}
check:
#include <bits/stdc++.h>
using namespace std;
int main() {
while (true) {
system("CF1464Fgen.exe > CF1464F.in");
system("CF1464F2.exe < CF1464F.in > CF1464F.out");
system("CF1464Fsol.exe < CF1464F.in > CF1464F.ans");
if (system("fc CF1464F.out CF1464F.ans /W")) {
system("pause");
return 0;
}
}
}