QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#79787 | #5437. Graph Completing | APJifengc | Compile Error | / | / | C++14 | 3.4kb | 2023-02-20 21:39:42 | 2023-02-20 21:39:46 |
Judging History
你现在查看的是最新测评结果
- [2023-08-10 23:21:45]
- System Update: QOJ starts to keep a history of the judgings of all the submissions.
- [2023-02-20 21:39:46]
- 评测
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2023-02-20 21:39:42]
- 提交
answer
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 7005, MAXM = 40005, P = 998244353;
int qpow(int a, long long b) {
int ans = 1;
while (b) {
if (b & 1) ans = 1ll * ans * a % P;
a = 1ll * a * a % P;
b >>= 1;
}
return ans;
}
int n, m;
int u[MAXM], v[MAXM];
#define forGraph(u, v) for (int i = fst[u], v = to[i]; i; i = nxt[i], v = to[i])
int f[MAXN][MAXN], g[MAXN][MAXN];
struct Tree {
int fst[MAXN], to[MAXM << 1], nxt[MAXM << 1], tot;
int siz[MAXN], cnt[MAXN], n;
int bl[MAXN];
void add(int u, int v) {
if (u == 0 || v == 0) {
printf("%d - %d\n", u, v);
}
to[++tot] = v, nxt[tot] = fst[u], fst[u] = tot;
}
void dfs(int u, int pre) {
f[u][siz[u]] = qpow(2, 1ll * siz[u] * (siz[u] - 1) / 2 - cnt[u]);
forGraph(u, v) if (v != pre) {
dfs(v, u);
for (int i = 0; i <= siz[u] + siz[v]; i++) {
g[u][i] = 0;
}
for (int i = 0; i <= siz[u]; i++) if (f[u][i]) {
for (int j = 0; j <= siz[v]; j++) if (f[v][j]) {
g[u][i + j] = (g[u][i + j] + 1ll * f[u][i] * f[v][j] % P *
qpow(2, 1ll * i * j - 1)) % P;
g[u][i] = (g[u][i] - 1ll * f[u][i] * f[v][j] % P + P) % P;
}
}
for (int i = 0; i <= siz[u] + siz[v]; i++) {
f[u][i] = g[u][i];
}
siz[u] += siz[v];
}
}
} t;
int aaaaaaa;
struct Graph {
int fst[MAXN], to[MAXM << 1], nxt[MAXM << 1], tot;
Graph() : tot(1) {}
void add(int u, int v) {
to[++tot] = v, nxt[tot] = fst[u], fst[u] = tot;
}
int dfn[MAXN], low[MAXN], dcnt;
bool vis[MAXN];
stack<int> st;
void tarjan(int u, int inEdge) {
dfn[u] = low[u] = ++dcnt;
st.push(u);
forGraph(u, v) if (!dfn[v]) {
tarjan(v, i ^ 1);
low[u] = min(low[u], low[v]);
if (low[v] > dfn[u]) {
vis[i] = vis[i ^ 1] = 1;
}
} else if (i != inEdge) {
low[u] = min(low[u], dfn[v]);
}
}
void dfs(int u, int id) {
t.bl[u] = id;
t.siz[id]++;
forGraph(u, v) if (!vis[i] && !t.bl[v]) {
dfs(v, id);
}
}
} G;
int main() {
// freopen("E.in", "r", stdin);
scanf("%d%d", &n, &m);
setbuf(stdout, nullptr);
for (int i = 1; i <= m; i++) {
scanf("%d%d", &u[i], &v[i]);
G.add(u[i], v[i]);
G.add(v[i], u[i]);
}
G.tarjan(1, 0);
for (int i = 1; i <= n; i++) if (!t.bl[i]) {
int id = ++t.n;
G.dfs(i, id);
}
for (int i = 1; i <= n; i++) if (!t.bl[i]) {
printf("bl[%d]=%d\b", i, bl[i]);
}
// if (n == 5000) {
// printf("%d\n", aaaaaaa);
// printf("n = %d\n", t.n);
// }
// for (int i = 1; i <= n; i++) {
// printf("bl[%d]=%d\n", i, t.bl[i]);
// }
// printf("m=%d\n", m);
for (int i = 1; i <= m; i++) {
if (t.bl[u[i]] == t.bl[v[i]]) {
t.cnt[t.bl[u[i]]]++;
} else {
t.add(t.bl[u[i]], t.bl[v[i]]);
t.add(t.bl[v[i]], t.bl[u[i]]);
}
}
t.dfs(1, 0);
int ans = 0;
for (int i = 0; i <= n; i++) {
ans = (ans + f[1][i]) % P;
}
printf("%d\n", ans);
return 0;
}
詳細信息
answer.code: In function ‘int main()’: answer.code:94:34: error: ‘bl’ was not declared in this scope 94 | printf("bl[%d]=%d\b", i, bl[i]); | ^~ answer.code:81:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 81 | scanf("%d%d", &n, &m); | ~~~~~^~~~~~~~~~~~~~~~ answer.code:84:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 84 | scanf("%d%d", &u[i], &v[i]); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~