QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#295828 | #6335. Belt Conveyor | chy12321 | 1 | 598ms | 33532kb | C++20 | 1.8kb | 2024-01-01 11:20:33 | 2024-01-01 11:20:33 |
Judging History
answer
#include <bits/stdc++.h>
#include "conveyor.h"
using namespace std;
constexpr int N = 1e5 + 10;
int dep[N], deg[N];
vector<int> G[N], d[3];
void Solve(int n, vector<int> a, vector<int> b) {
function<void(int, int)> dfs = [&](int u, int fa) {
for (int i : G[u]) {
int v = u ^ a[i] ^ b[i];
if (v != fa) dep[v] = dep[u] + 1, dfs(v, u);
}
};
vector<int> dir(n - 1, -1);
for (int i = 0; i < n - 1; i++) {
G[a[i]].emplace_back(i), G[b[i]].emplace_back(i);
deg[a[i]]++, deg[b[i]]++;
}
dfs(1, -1);
for (int i = 0; i < n; i++) d[dep[i] % 3].emplace_back(i);
while (!(d[0].empty() && d[1].empty() && d[2].empty())) {
sort(d, d + 3, [&](vector<int> x, vector<int> y) {return x.size() > y.size();});
vector<int> V(n), E(n - 1);
for (int u : d[0]) {
V[u] = 1;
for (int i : G[u]) {
if ((u == a[i] && dir[i] == 0) || (u == b[i] && dir[i] == 1)) E[i] = 1;
}
}
vector<int> now = Query(E, V);
for (int u : d[0]) {
if (now[u]) {
for (int i : G[u]) {
if (dir[i] == -1) {
dir[i] = u == b[i] ? 0 : 1;
deg[a[i]]--, deg[b[i]]--;
}
}
} else {
for (int i : G[u]) {
if (dir[i] == -1 && now[u ^ a[i] ^ b[i]]) {
dir[i] = u == a[i] ? 0 : 1;
deg[a[i]]--, deg[b[i]]--;
}
}
}
}
for (int i = 0; i < 3; i++) {
for (int j = d[i].size() - 1; j >= 0; j--) {
if (!deg[d[i][j]]) d[i].erase(d[i].begin() + j);
}
}
}
Answer(dir);
}
詳細信息
Subtask #1:
score: 1
Accepted
Test #1:
score: 1
Accepted
time: 1ms
memory: 6124kb
input:
random1 2 0 1 1 0xC321A02965AC2640
output:
Accepted: 1
result:
ok correct
Test #2:
score: 0
Accepted
time: 0ms
memory: 6400kb
input:
random1 2 1 0 0 0x8A99AD9552B2C218
output:
Accepted: 1
result:
ok correct
Test #3:
score: 0
Accepted
time: 1ms
memory: 6088kb
input:
random1 2 1 0 1 0x024D21FA307D148D
output:
Accepted: 1
result:
ok correct
Test #4:
score: 0
Accepted
time: 1ms
memory: 6132kb
input:
random1 2 0 1 0 0x3C96AB23CEB63F75
output:
Accepted: 1
result:
ok correct
Subtask #2:
score: 0
Wrong Answer
Dependency #1:
100%
Accepted
Test #5:
score: 0
Wrong Answer
time: 1ms
memory: 6180kb
input:
priority 30 10 29 10 13 17 11 2 15 15 27 9 26 18 0 14 1 22 24 29 28 6 22 4 20 15 5 28 4 21 24 3 13 1 8 13 12 8 19 16 3 1 10 24 29 12 8 4 7 2 7 28 25 12 7 2 23 27 22 89058848 6377689 24189123 31671827 205117644 254374430 56016068 6819602 212866321 246625321 274047319 230485311 202854776 280075001 203...
output:
Wrong Answer [8]
result:
wrong answer Token "Wrong" doesn't correspond to pattern "Accepted:"
Subtask #3:
score: 0
Wrong Answer
Test #11:
score: 0
Wrong Answer
time: 598ms
memory: 33532kb
input:
random1 100000 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 9...
output:
Wrong Answer [8]
result:
wrong answer Token "Wrong" doesn't correspond to pattern "Accepted:"
Subtask #4:
score: 0
Skipped
Dependency #1:
100%
Accepted
Dependency #2:
0%