QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#84334 | #4511. Wonderland Chase | a_z_c | Compile Error | / | / | C++14 | 2.6kb | 2023-03-06 10:58:18 | 2023-03-06 10:58:22 |
Judging History
你现在查看的是最新测评结果
- [2023-08-10 23:21:45]
- System Update: QOJ starts to keep a history of the judgings of all the submissions.
- [2023-03-06 10:58:22]
- 评测
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2023-03-06 10:58:18]
- 提交
answer
// Problem: #4511. Wonderland Chase
// Contest:
// URL: https://qoj.ac/problem/4511
// Memory Limit: 1024 MB
// Time Limit: 1000 ms
//
// Powered by CP Editor (https://cpeditor.org)
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
const int inf = 0x3f3f3f3f;
vector<int> G[maxn];
int disa[maxn], disb[maxn];
int a, b, n, m;
queue<int> q;
void bfs1() {
q.emplace(a);
disa[a] = 1;
while (!q.empty()) {
int u = q.front();
q.pop();
for (int v : G[u]) {
if (!disa[v]) {
disa[v] = disa[u] + 1;
q.push(v);
}
}
}
}
void bfs2() {
q.emplace(b);
disb[b] = 1;
while (!q.empty()) {
int u = q.front();
q.pop();
for (int v : G[u]) {
if (!disb[v]) {
disb[v] = disb[u] + 1;
q.push(v);
}
}
}
}
bool vis[maxn], safe[maxn];
int stk[maxn], cnt;
void dfs(int u, int fa) {
vis[u] = 1;
stk[++cnt] = u;
for (int v : G[u]) {
if (v == fa)
continue;
if (vis[v]) {
for (int i = cnt; i > 0; i--) {
safe[stk[i]] = true;
if (stk[i] == v)
break;
}
} else
dfs(v, u);
}
cnt--;
}
void solve(int cas) {
memset(disa, 0, sizeof(disa));
memset(disb, 0, sizeof(disb));
memset(vis, 0, sizeof(vis));
memset(safe, 0, sizeof(safe));
cnt = 0;
scanf("%d%d%d%d", &n, &m, &a, &b);
for (int i = 1; i <= n; i++) G[i].clear();
for (int i = 1; i <= m; i++) {
int u, v;
scanf("%d%d", &u, &v);
G[u].emplace_back(v);
G[v].emplace_back(u);
}
bfs1();
bfs2();
dfs(1, 1);
if (disb[a] == 0) {
printf("Case #%d: SAFE\n", cas);
s return;
}
// for (int i = 1; i <= n; i++) printf("%d ", disa[i]);
// printf("\n");
// for (int i = 1; i <= n; i++) printf("%d ", disb[i]);
// printf("\n");
// for (int i = 1; i <= n; i++) printf("%d ", (int)safe[i]);
// printf("\n");
int dep = 0;
for (int i = 1; i <= n; i++) {
if (safe[i] && disa[i] < disb[i]) {
printf("Case #%d: SAFE\n", cas);
return;
}
if (disa[i] < disb[i]) {
dep = max(dep, disb[i]);
}
}
printf("Case #%d: %d\n", cas, (dep - 1) * 2);
}
int t;
int main() {
scanf("%d", &t);
for (int i = 1; i <= t; i++) {
solve(i);
}
}
Details
answer.code: In function ‘void solve(int)’: answer.code:83:9: error: ‘s’ was not declared in this scope 83 | s return; | ^ answer.code:70:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 70 | scanf("%d%d%d%d", &n, &m, &a, &b); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~ answer.code:74:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 74 | scanf("%d%d", &u, &v); | ~~~~~^~~~~~~~~~~~~~~~ answer.code: In function ‘int main()’: answer.code:105:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 105 | scanf("%d", &t); | ~~~~~^~~~~~~~~~