QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#328182 | #1844. Cactus | lhzawa | Compile Error | / | / | C++14 | 2.2kb | 2024-02-15 17:57:38 | 2024-02-15 17:57:38 |
Judging History
answer
#include<bits/stdc++.h>
const int maxn = 3e5 + 10, maxN = maxn * 2;
int n, m, N;
std::vector<int> qr;
std::vector<int> G[maxn], E[maxN];
bool vis[maxn];
int deg[maxn];
int dfn[maxn], low[maxn], stk[maxn], top, dt;
void dfs(int u) {
dfn[u] = low[u] = ++dt, stk[++top] = u;
for (int v : G[u]) {
if (vis[v]) continue;
if (! dfn[v]) {
dfs(v);
low[u] = std::min(low[u], low[v]);
if (dfn[u] == low[v]) {
N++;
for (int t = 0; t != v; ) {
t = stk[top--];
E[t].push_back(N), E[N].push_back(t);
}
E[u].push_back(N), E[N].push_back(u);
}
} else low[u] = std::min(low[u], dfn[v]);
}
}
void solve(int u, int fa) {
for (int v : E[u]) v != fa && (solve(v, u), 1);
if (u > n) {
std::vector<int> P;
for (int i = 0, cnt = 0; cnt < 2; cnt += E[u][i] == fa, (++i) %= E[u].size())
cnt == 1 && E[u][i] != fa && (P.push_back(E[u][i]), 1);
int op = 0;
for (int v : P) qr.push_back(v + op * n), op ^= 1;
qr.push_back(P.front() + n), qr.push_back(P.back() + op * n);
}
}
int main() {
std::map<std::pair<int, int>, bool> F;
scanf("%d%d", &n, &m);
for (int i = 1; i <= m; i++) {
int x, y; scanf("%d%d", &x, &y);
assert(! F[{x, y}]), F[{x, y}] = F[{y, x}] = 1;
G[x].push_back(y), G[y].push_back(x);
deg[x]++, deg[y]++;
}
std::vector<int> q1;
std::queue<int> q;
for (int i = 1; i <= n; i++) deg[i] <= 1 && (q.push(i), 1);
while (! q.empty()) {
int u = q.front(); q.pop();
! vis[u] && (q1.push_back(u), vis[u] = 1);
if (! deg[u]) continue;
qr.push_back(u);
deg[u]--;
for (int v : G[u]) if (deg[v]) (--deg[v]) <= 1 && (q.push(v), 1);
}
qr.push_back(0);
for (int x : q1) qr.push_back(x);
N = n;
for (int i = 1; i <= n; i++) {
if (vis[i] || dfn[i]) continue;
top = 0, dfs(i);
solve(i, 0);
qr.push_back(i);
}
printf("0 %zu\n", qr.size());
for (int x : qr) ! x ? puts("2") : printf("1 %d\n", x);
return 0;
}
Details
answer.code:43:35: error: macro "assert" passed 2 arguments, but takes just 1 43 | assert(! F[{x, y}]), F[{x, y}] = F[{y, x}] = 1; | ^ In file included from /usr/include/c++/13/cassert:44, from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:106, from answer.code:1: /usr/include/assert.h:92: note: macro "assert" defined here 92 | # define assert(expr) \ | answer.code: In function ‘int main()’: answer.code:43:17: error: ‘assert’ was not declared in this scope 43 | assert(! F[{x, y}]), F[{x, y}] = F[{y, x}] = 1; | ^~~~~~ answer.code:2:1: note: ‘assert’ is defined in header ‘<cassert>’; did you forget to ‘#include <cassert>’? 1 | #include<bits/stdc++.h> +++ |+#include <cassert> 2 | const int maxn = 3e5 + 10, maxN = maxn * 2; answer.code:40:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 40 | scanf("%d%d", &n, &m); | ~~~~~^~~~~~~~~~~~~~~~ answer.code:42:24: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 42 | int x, y; scanf("%d%d", &x, &y); | ~~~~~^~~~~~~~~~~~~~~~