QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#296080 | #6335. Belt Conveyor | A_programmer | Compile Error | / | / | C++20 | 2.0kb | 2024-01-02 07:56:52 | 2024-01-02 07:56:53 |
Judging History
answer
#include <bits/stdc++.h>
#include "conveyor.h"
using namespace std;
vector<int> p[3];
vector<pii> g[maxn];
int deg[maxn], fa[maxn], cnt[3];
vector<int> ans;
void dfs(int u, int fu, int dep)
{
fa[u] = fu;
p[dep].emplace_back(u);
for (pii tmp : g[u])
{
int v = tmp.first;
if (v == fu) continue;
dfs(v, u, (dep + 1) % 3);
}
}
void Solve(int N, vector<int> A, vector<int> B)
{
for (int i = 0; i <= N - 2; i++)
{
A[i]++, B[i]++;
deg[A[i]]++, deg[B[i]]++;
g[A[i]].emplace_back(make_pair(B[i], i)), g[B[i]].emplace_back(make_pair(A[i], i));
}
ans.resize(N - 1);
for (int i = 0; i <= N - 2; i++) ans[i] = -1;
dfs(1, 0, 0);
while (1)
{
cnt[0] = cnt[1] = cnt[2] = 0;
for (int i = 0; i < 3; i++)
for (int u : p[i]) if (deg[u]) cnt[i]++;
int pos;
if (cnt[0] > cnt[1] && cnt[0] > cnt[2]) pos = 0;
else if (cnt[1] > cnt[2]) pos = 1;
else pos = 2;
if (!cnt[pos]) break;
vector<int> x, y, res;
x.resize(N - 1), y.resize(N);
for (int u : p[pos])
{
y[u - 1] = 1;
for (pii tmp : g[u])
{
int v = tmp.first, id = tmp.second;
if (ans[id] == -1) continue;
x[id] = (u == A[id]) ^ ans[id];
}
}
res = Query(x, y);
for (int u : p[pos])
{
if (res[u - 1])
{
for (pii tmp : g[u])
{
int v = tmp.first, id = tmp.second;
if (ans[id] != -1) continue;
ans[id] = (u == A[id]);
deg[u]--, deg[v]--;
}
}
else
{
bool Fl = false;
for (pii tmp : g[u])
{
int v = tmp.first, id = tmp.second;
if (v == fa[u]) continue;
if (res[v - 1])
{
Fl = true;
deg[u]--, deg[v]--;
ans[id] = (u != A[id]);
break;
}
}
if (!Fl)
{
for (pii tmp : g[u])
{
int v = tmp.first, id = tmp.second;
if (v == fa[u])
{
deg[u]--, deg[v]--;
ans[id] = (u != A[id]);
break;
}
}
}
}
}
}
Answer(ans);
}
Details
answer.code:6:8: error: ‘pii’ was not declared in this scope 6 | vector<pii> g[maxn]; | ^~~ answer.code:6:11: error: template argument 1 is invalid 6 | vector<pii> g[maxn]; | ^ answer.code:6:11: error: template argument 2 is invalid answer.code:6:15: error: ‘maxn’ was not declared in this scope 6 | vector<pii> g[maxn]; | ^~~~ answer.code:7:9: error: ‘maxn’ was not declared in this scope 7 | int deg[maxn], fa[maxn], cnt[3]; | ^~~~ answer.code:7:19: error: ‘maxn’ was not declared in this scope 7 | int deg[maxn], fa[maxn], cnt[3]; | ^~~~ answer.code: In function ‘void dfs(int, int, int)’: answer.code:12:9: error: ‘fa’ was not declared in this scope; did you mean ‘fu’? 12 | fa[u] = fu; | ^~ | fu answer.code:14:14: error: ‘pii’ was not declared in this scope 14 | for (pii tmp : g[u]) | ^~~ answer.code:20:1: error: expected primary-expression before ‘}’ token 20 | } | ^ answer.code:19:10: error: expected ‘;’ before ‘}’ token 19 | } | ^ | ; 20 | } | ~ answer.code:20:1: error: expected primary-expression before ‘}’ token 20 | } | ^ answer.code:19:10: error: expected ‘)’ before ‘}’ token 19 | } | ^ | ) 20 | } | ~ answer.code:14:13: note: to match this ‘(’ 14 | for (pii tmp : g[u]) | ^ answer.code:20:1: error: expected primary-expression before ‘}’ token 20 | } | ^ answer.code: In function ‘void Solve(int, std::vector<int>, std::vector<int>)’: answer.code:27:17: error: ‘deg’ was not declared in this scope 27 | deg[A[i]]++, deg[B[i]]++; | ^~~ answer.code:28:17: error: ‘g’ was not declared in this scope 28 | g[A[i]].emplace_back(make_pair(B[i], i)), g[B[i]].emplace_back(make_pair(A[i], i)); | ^ answer.code:37:48: error: ‘deg’ was not declared in this scope 37 | for (int u : p[i]) if (deg[u]) cnt[i]++; | ^~~ answer.code:49:30: error: ‘pii’ was not declared in this scope 49 | for (pii tmp : g[u]) | ^~~ answer.code:55:17: error: expected primary-expression before ‘}’ token 55 | } | ^ answer.code:54:26: error: expected ‘;’ before ‘}’ token 54 | } | ^ | ; 55 | } | ~ answer.code:55:17: error: expected primary-expression before ‘}’ token 55 | } | ^ answer.code:54:26: error: expected ‘)’ before ‘}’ token 54 | } | ^ | ) 55 | } | ~ answer.code:49:29: note: to match this ‘(’ 49 | for (pii tmp : g[u]) | ^ answer.code:55:17: error: expected primary-expression before ‘}’ token 55 | } | ^ answer.code:62:38: error: ‘pii’ was not declared in this scope 62 | for (pii tmp : g[u]) | ^~~ answer.code:69:25: error: expected primary-expression before ‘}’ token 69 | } | ^ answer.code:68:34: error: expected ‘;’ before ‘}’ token 68 | } | ^ | ; 69 | } | ~ answer.code:69:25: error: expected primary-expression before ‘}’ token 69 | } | ^ answer.code:68:34: error: expected ‘)’ before ‘}’ token 68 | } | ^ | ) 69 | } | ~ answer.code:62:37: note: to match this ‘(’ 62 | for (pii tmp : g[u]) | ^ answer.code:69:25: error: expected primary-expression before ‘}’ token 69 | } | ^ answer.code:73:38: error: ‘pii’ was not declared in this scope 73 | for (pii tmp : g[u]) | ^~~ answer.code:86:33: error: expected primary-expression before ‘if’ 86 | if (!Fl) | ^~ answer.code:84:34: error: expected ‘;’ before ‘if’ 84 | ...