QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#676033 | #996. 割点 | Poetry# | WA | 5ms | 5052kb | C++23 | 1.1kb | 2024-10-25 20:03:31 | 2024-10-25 20:03:32 |
Judging History
answer
#include <bits/stdc++.h>
using u32 = unsigned;
using i64 = long long;
using u64 = unsigned long long;
constexpr int N = 2E4 + 5;
int n, m;
int dfn[N], low[N], tot;
std::vector<int> adj[N];
bool cut[N];
void tarjan(int x, int fa) {
dfn[x] = low[x] = ++tot;
int deg = 0;
for (auto v : adj[x]) {
if (!dfn[v]) {
tarjan(v, x);
++deg;
low[x] = std::min(low[x], low[v]);
if (low[v] >= dfn[x] && !cut[v] && fa) cut[x] = 1;
} else if (v != fa) {
low[x] = std::min(low[x], dfn[v]);
}
}
if (fa == 0 && deg > 1) cut[x] = 1;
}
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
std::cin >> n >> m;
for (int i = 1; i <= m; ++i) {
int u, v;
std::cin >> u >> v;
adj[u].push_back(v);
adj[v].push_back(u);
}
for (int i = 1; i <= n; ++i) {
if (!dfn[i])
tarjan(i, 0);
}
std::vector<int> ans;
for (int i = 1; i <= n; ++i)
if (cut[i]) ans.push_back(i);
std::cout << ans.size() << "\n";
for (auto x : ans)
std::cout << x << " \n"[x == ans.back()];
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 5ms
memory: 5052kb
input:
12783 21968 4933 7832 8238 2739 3628 7841 9169 6390 7850 8797 8120 8710 5306 9807 10166 2063 2666 5157 5015 4651 4790 12586 10366 7137 12440 7218 6330 3670 2735 8492 1968 2750 6237 1112 6578 9221 743 3820 7155 4583 2537 9747 11331 9916 4454 5631 2978 10340 5293 1803 4944 4296 11800 2742 7903 2018 10...
output:
1286 13 22 26 27 29 33 35 39 45 47 53 62 78 91 127 132 144 151 155 163 166 168 183 187 192 196 205 219 220 223 225 239 248 250 254 256 265 285 290 313 315 337 338 347 358 376 388 408 414 415 427 446 459 461 464 477 486 504 513 519 538 555 557 571 574 611 619 625 626 633 639 644 647 653 659 691 694 6...
result:
wrong answer 1st numbers differ - expected: '1440', found: '1286'