5564 | 2023-07-27 11:25:12 | zsombor | Széfnyitás | cpp17 | Wrong answer 0/100 | 9ms | 11432 KiB |
#include <iostream>
#include <vector>
#include <set>
using namespace std;
int n, k;
vector <int> B(3e4, 0);
vector <vector <int>> T(3e4, vector <int>(2, 1));
vector <vector <int>> t(3e4, vector <int>(2, 1));
vector <int> cur(3e4, 1);
void solve(set <int> s) {
/*cout << endl << i << " ";
for (int l = 1; l <= n; l++) cout << v[l] << " ";
cout << " ";
for (int l = 1; l <= n; l++) cout << cur[l] << " ";*/
int i = *s.begin(), J = cur[i], j = cur[i];
vector <set <int>> v(n + 1);
for (int cnt = 0; cnt < 23000; cnt++) {
for (int l = 1; l <= n; l++) {
if (!s.count(l)) continue;
if (B[cur[l]] != B[j]) {
s.erase(l);
v[j].insert(l);
}
cur[l] = T[cur[l]][B[j]];
}
j = T[j][B[j]];
}
j = J;
for (int cnt = 0; cnt < n; cnt++) {
if (v[j].empty()) { j = T[j][B[j]]; continue; }
t[(i - 1) * n + j][1 - B[j]] = ((*v[j].begin()) - 1) * n + cur[*v[j].begin()];
solve(v[j]);
v[j].clear();
j = T[j][B[j]];
}
}
int test(int A) {
int a = A, b = 1, cnt = 0;
for (int i = 0; i < 1e2; i++) {
int x = B[a], y = B[(b % n ? b % n : n)];
cout << a << " " << b << " " << x << " " << y << endl;
if (x != y) cnt++;
a = T[a][y]; b = t[b][x];
}
if (cnt >= k) cout << A << " ";
return cnt;
}
bool teszt = 1;
int main() {
if (teszt) {
n = 3;
k = n;
srand(time(0));
for (int i = 1; i <= n; i++) {
B[i] = rand() % 2;
T[i][0] = rand() % n + 1;
T[i][1] = rand() % n + 1;
}
cout << "bemenet:\n";
for (int i = 1; i <= n; i++) {
cout << B[i] << " " << T[i][0] << " " << T[i][1] << endl;
}
cout << endl;
}
else {
cin >> n;
for (int i = 1; i <= n; i++) cin >> B[i] >> T[i][0] >> T[i][1];
cin >> k;
}
set <int> s;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n; j++) {
t[(i - 1) * n + j][0] = (i - 1) * n + T[j][0];
t[(i - 1) * n + j][1] = (i - 1) * n + T[j][1];
}
cur[i] = i;
s.insert(i);
}
solve(s);
cout << n * n << " 1\n";
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n; j++) {
cout << B[j] << " " << t[(i - 1) * n + j][0] << " " << t[(i - 1) * n + j][1] << "\n";
}
}
cout << endl;
bool jo = true;
//for (int i = 1; i <= n; i++) if (test(i) >= k) jo = false;
test(3);
cout << endl << (jo ? "HELYES" : "ROSSZ");
}
/*
5
1 5 1
1 1 4
0 5 4
0 2 3
0 2 2
5
3
1 2 1
0 1 3
0 2 2
3
*/
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Wrong answer | 9ms | 8552 KiB | ||||
2 | Wrong answer | 9ms | 8856 KiB | ||||
subtask2 | 0/16 | ||||||
3 | Wrong answer | 8ms | 9148 KiB | ||||
4 | Wrong answer | 9ms | 9364 KiB | ||||
5 | Wrong answer | 8ms | 9208 KiB | ||||
6 | Wrong answer | 9ms | 9340 KiB | ||||
7 | Wrong answer | 9ms | 9552 KiB | ||||
8 | Wrong answer | 9ms | 9568 KiB | ||||
9 | Wrong answer | 9ms | 9824 KiB | ||||
10 | Wrong answer | 9ms | 10032 KiB | ||||
11 | Wrong answer | 8ms | 10332 KiB | ||||
12 | Wrong answer | 8ms | 10288 KiB | ||||
13 | Wrong answer | 8ms | 10248 KiB | ||||
subtask3 | 0/24 | ||||||
14 | Wrong answer | 9ms | 10340 KiB | ||||
15 | Wrong answer | 9ms | 10644 KiB | ||||
16 | Wrong answer | 8ms | 10600 KiB | ||||
17 | Wrong answer | 8ms | 10600 KiB | ||||
18 | Wrong answer | 8ms | 10496 KiB | ||||
19 | Wrong answer | 8ms | 10684 KiB | ||||
20 | Wrong answer | 9ms | 10644 KiB | ||||
21 | Wrong answer | 9ms | 10692 KiB | ||||
subtask4 | 0/23 | ||||||
22 | Wrong answer | 8ms | 10728 KiB | ||||
23 | Wrong answer | 8ms | 10980 KiB | ||||
24 | Wrong answer | 9ms | 10784 KiB | ||||
25 | Wrong answer | 8ms | 10824 KiB | ||||
26 | Wrong answer | 8ms | 10820 KiB | ||||
27 | Wrong answer | 9ms | 10908 KiB | ||||
28 | Wrong answer | 8ms | 10948 KiB | ||||
29 | Wrong answer | 9ms | 10924 KiB | ||||
subtask5 | 0/37 | ||||||
30 | Wrong answer | 8ms | 9148 KiB | ||||
31 | Wrong answer | 9ms | 9364 KiB | ||||
32 | Wrong answer | 8ms | 9208 KiB | ||||
33 | Wrong answer | 9ms | 9340 KiB | ||||
34 | Wrong answer | 9ms | 9552 KiB | ||||
35 | Wrong answer | 9ms | 9568 KiB | ||||
36 | Wrong answer | 9ms | 9824 KiB | ||||
37 | Wrong answer | 9ms | 10032 KiB | ||||
38 | Wrong answer | 8ms | 10332 KiB | ||||
39 | Wrong answer | 8ms | 10288 KiB | ||||
40 | Wrong answer | 8ms | 10248 KiB | ||||
41 | Wrong answer | 9ms | 10340 KiB | ||||
42 | Wrong answer | 9ms | 10644 KiB | ||||
43 | Wrong answer | 8ms | 10600 KiB | ||||
44 | Wrong answer | 8ms | 10600 KiB | ||||
45 | Wrong answer | 8ms | 10496 KiB | ||||
46 | Wrong answer | 8ms | 10684 KiB | ||||
47 | Wrong answer | 9ms | 10644 KiB | ||||
48 | Wrong answer | 9ms | 10692 KiB | ||||
49 | Wrong answer | 8ms | 10728 KiB | ||||
50 | Wrong answer | 8ms | 10980 KiB | ||||
51 | Wrong answer | 9ms | 10784 KiB | ||||
52 | Wrong answer | 8ms | 10824 KiB | ||||
53 | Wrong answer | 8ms | 10820 KiB | ||||
54 | Wrong answer | 9ms | 10908 KiB | ||||
55 | Wrong answer | 8ms | 10948 KiB | ||||
56 | Wrong answer | 9ms | 10924 KiB | ||||
57 | Wrong answer | 9ms | 11184 KiB | ||||
58 | Wrong answer | 8ms | 11264 KiB | ||||
59 | Wrong answer | 8ms | 11304 KiB | ||||
60 | Wrong answer | 9ms | 11240 KiB | ||||
61 | Wrong answer | 9ms | 11236 KiB | ||||
62 | Wrong answer | 9ms | 11432 KiB | ||||
63 | Wrong answer | 8ms | 11344 KiB | ||||
64 | Wrong answer | 8ms | 11344 KiB | ||||
65 | Wrong answer | 8ms | 11348 KiB | ||||
66 | Wrong answer | 8ms | 11360 KiB | ||||
67 | Wrong answer | 8ms | 11356 KiB | ||||
68 | Wrong answer | 8ms | 11352 KiB |