QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#100633 | #6329. Colorful Graph | SolitaryDream# | Compile Error | / | / | C++20 | 2.2kb | 2023-04-27 14:36:23 | 2023-04-27 14:36:24 |
Judging History
你现在查看的是最新测评结果
- [2023-08-10 23:21:45]
- System Update: QOJ starts to keep a history of the judgings of all the submissions.
- [2023-04-27 14:36:24]
- 评测
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2023-04-27 14:36:23]
- 提交
answer
#include <bits/stdc++.h>
using namespace std;
const int N = 7010;
int n, m;
vector<int> g[N], h[N];
int fa[N];
int col[N], colnum, dfn[N], low[N], dclk;
int deg[N], ins[N];
stack<int> sta;
inline int Ask(int x) {
return fa[x] ? fa[x] = Ask(fa[x]) : x;
}
inline void Tarjan(int x) {
sta.push(x); ins[x] = 1;
dfn[x] = low[x] = ++dclk;
for (auto y : g[x])
if (!dfn[y]) Tarjan(y), low[x] = min(low[x], low[y]);
else if (ins[y]) low[x] = min(low[x], dfn[y]);
if (low[x] == dfn[x]) {
col[x] = ++colnum;
while (sta.top() != x) {
col[sta.top()] = colnum;
ins[sta.top()] = 0;
sta.pop();
}
ins[x] = 0;
sta.pop();
}
}
int vis[N], link[N];
inline int Dfs(int x) {
if (vis[x]) return 0;
vis[x] = 1;
for (auto y : h[x]) if (!link[y] || Dfs(link[y])) {
link[y] = x;
return 1;
}
return 0;
}
int ans[N];
inline void Topo() {
int paint = 0;
queue<int> q;
for (int x = 1; x <= colnum; ++x) if (deg[x] == 0) q.push(x);
while (!q.empty()) {
int u = q.front(); q.pop();
if (link[u]) ans[u] = ans[link[u]];
else ans[u] = ++paint;
for (auto y : h[u]) if (--deg[y] == 0) {
deg[y] = -1;
q.push(y);
}
}
}
vector<int> st[N];
int main() {
scanf("%d%d", &n, &m);
for (int i = 1, x, y; i <= m; ++i) {
scanf("%d%d", &x, &y);
g[x].push_back(y);
}
for (int i = 1; i <= n; ++i) if (!dfn[i]) {
Tarjan(i);
}
for (int x = 1; x <= n; ++x)
for (auto y : g[x]) if (col[x] != col[y]) {
h[col[x]].push_back(col[y]);
++deg[col[y]];
int u = Ask(col[x]), v = Ask(col[y]);
if (u != v) fa[u] = v;
}
for (int i = 1; i <= colnum; ++i) {
memset(vis + 1, 0, colnum * sizeof *col);
Dfs(i);
}
// for (int i = 1; i <= colnum; ++i) st[Ask(i)].push_back(i);
// for (int i = 1; i <= colnum; ++i) if (st[i].size()) {
Topo();
// }
for (int i = 1; i <= n; ++i) printf("%d%c", ans[col[i]], " \n"[i == n]);
return 0;
}
详细
answer.code:31:19: error: ‘int link [7010]’ redeclared as different kind of entity 31 | int vis[N], link[N]; | ^ In file included from /usr/include/c++/11/bits/atomic_wait.h:44, from /usr/include/c++/11/bits/atomic_base.h:41, from /usr/include/c++/11/bits/shared_ptr_atomic.h:33, from /usr/include/c++/11/memory:78, from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:82, from answer.code:2: /usr/include/unistd.h:789:12: note: previous declaration ‘int link(const char*, const char*)’ 789 | extern int link (const char *__from, const char *__to) | ^~~~ answer.code: In function ‘int Dfs(int)’: answer.code:35:36: warning: pointer to a function used in arithmetic [-Wpointer-arith] 35 | for (auto y : h[x]) if (!link[y] || Dfs(link[y])) { | ^ answer.code:35:51: warning: pointer to a function used in arithmetic [-Wpointer-arith] 35 | for (auto y : h[x]) if (!link[y] || Dfs(link[y])) { | ^ answer.code:35:51: error: invalid conversion from ‘int (*)(const char*, const char*) noexcept’ to ‘int’ [-fpermissive] 35 | for (auto y : h[x]) if (!link[y] || Dfs(link[y])) { | ~~~~~~^ | | | int (*)(const char*, const char*) noexcept answer.code:32:20: note: initializing argument 1 of ‘int Dfs(int)’ 32 | inline int Dfs(int x) { | ~~~~^ answer.code:36:15: warning: pointer to a function used in arithmetic [-Wpointer-arith] 36 | link[y] = x; | ^ answer.code:36:17: error: assignment of read-only location ‘*(link + ((sizetype)y))’ 36 | link[y] = x; | ~~~~~~~~^~~ answer.code: In function ‘void Topo()’: answer.code:48:19: warning: pointer to a function used in arithmetic [-Wpointer-arith] 48 | if (link[u]) ans[u] = ans[link[u]]; | ^ answer.code:48:41: warning: pointer to a function used in arithmetic [-Wpointer-arith] 48 | if (link[u]) ans[u] = ans[link[u]]; | ^ answer.code:48:34: error: invalid types ‘int [7010][int(const char*, const char*) noexcept]’ for array subscript 48 | if (link[u]) ans[u] = ans[link[u]]; | ^ answer.code: In function ‘int main()’: answer.code:58:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 58 | scanf("%d%d", &n, &m); | ~~~~~^~~~~~~~~~~~~~~~ answer.code:60:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 60 | scanf("%d%d", &x, &y); | ~~~~~^~~~~~~~~~~~~~~~