| 25624 | 2026-02-23 18:01:55 | Generatroll | Hölgy vagy tigris trükk (45 pont) | cpp17 | Compilation error |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int q;
cin >> q;
while (q--) {
int n, m;
cin >> n >> m;
vector<vector<int>> g(2 * n);
auto f = [&](int u1, int v1) {
g[u1 ^ 1].push_back(v1);
g[v1 ^ 1].push_back(u1);
};
for (int i = 0; i < m; i++) {
int a, b, e;
char x, y, z;
cin >> a >> x >> b >> y >> c >> z;
int u = (x == 'H' ? 2 * (a - 1) : 2 * (a - 1) + 1);
int v = (y == 'H' ? 2 * (b - 1) : 2 * (b - 1) + 1);
int w = (z == 'H' ? 2 * (e - 1) : 2 * (e - 1) + 1);
f(u, v);
f(u, w);
f(v, w);
}
vector<int> d(2 * n, 0);
vector<int> l(2 * n, 0);
vector<int> s(2 * n, 0);
vector<bool> k(2 * n, false);
vector<int> p;
int r = 0;
int c = 0;
auto t = [&](auto self, int u) -> void {
r++;
d[u] = l[u] = r;
p.push_back(u);
k[u] = true;
for (int v1 : g[u]) {
if (!d[v1]) {
self(self, v1);
l[u] = min(l[u], l[v1]);
} else if (k[v1]) {
l[u] = min(l[u], d[v1]);
}
}
if (l[u] == d[u]) {
c++;
while (true) {
int v1 = p.back();
p.pop_back();
k[v1] = false;
s[v1] = c;
if (u == v1) {
break;
}
}
}
};
for (int i = 0; i < 2 * n; i++) {
if (!d[i]) {
t(t, i);
}
}
bool o = true;
for (int i = 0; i < n; i++) {
if (s[2 * i] == s[2 * i + 1]) {
o = false;
break;
}
}
if (o) {
for (int i = 0; i < n; i++) {
if (i > 0) {
cout << ' ';
}
if (s[2 * i] < s[2 * i + 1]) {
cout << 'H';
} else {
cout << 'T';
}
}
cout << '\n';
} else {
cout << -1 << '\n';
}
}
return 0;
}open /var/local/lib/isolate/425/box/a.out: no such file or directory
main.cpp: In function 'int main()':
main.cpp:19:52: error: 'c' was not declared in this scope
19 | cin >> a >> x >> b >> y >> c >> z;
| ^