QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#202674 | #5531. ICC | Camillus | 7 | 174ms | 4304kb | C++20 | 1.4kb | 2023-10-06 12:59:17 | 2024-07-01 04:28:23 |
Judging History
answer
#include "bits/stdc++.h"
#include "icc.h"
using namespace std;
struct dsu {
vector<int> p;
vector<vector<int>> d;
dsu(int n) {
p.resize(n);
d.resize(n);
for (int i = 0; i < n; i++) {
p[i] = i;
d[i] = {i};
}
}
int get(int u) {
if (u == p[u]) {
return u;
} else {
return p[u] = get(p[u]);
}
}
void join(int u, int v) {
u = get(u);
v = get(v);
if (u == v) {
return;
}
if (d[v].size() > d[u].size()) {
swap(u, v);
}
p[v] = u;
d[u].insert(d[u].end(), d[v].begin(), d[v].end());
d[v].clear();
}
};
void run(int n) {
dsu Q(n + 1);
auto loop = [&]() {
for (int u = 1; u <= n; u++) {
for (int v = 1; v <= n; v++) {
if (Q.get(u) != Q.get(v)) {
int x = min(u, v);
int y = max(u, v);
if (query(1, 1, &x, &y)) {
setRoad(x, y);
Q.join(x, y);
return;
}
}
}
}
};
for (int i = 0; i < n - 1; i++) {
loop();
}
}
#ifdef LOCAL
int main() {
int n;
cin >> n;
run(n);
}
#endif
詳細信息
Subtask #1:
score: 7
Accepted
Test #1:
score: 7
Accepted
time: 44ms
memory: 4156kb
input:
1 1500 3 15 0 2 0.0 2.5 0 3.5 0 1 1
output:
3 Ok! 1470 queries used.
result:
ok
Test #2:
score: 0
Accepted
time: 40ms
memory: 4152kb
input:
1 1500 4 15 0 0 0.0 3.5 0 2.5 5 1 1
output:
4 Ok! 1466 queries used.
result:
ok
Subtask #2:
score: 0
Wrong Answer
Test #3:
score: 0
Wrong Answer
time: 157ms
memory: 4088kb
input:
1 2500 4 50 0 0 0.0 3.5 0 2.5 5 1 1
output:
0 Number of queries more than 5000 out of 2500
result:
wrong answer
Subtask #3:
score: 0
Wrong Answer
Test #6:
score: 0
Wrong Answer
time: 174ms
memory: 4304kb
input:
1 2250 6 100 0.05 2.3 0.1 0.7 0 1.5 1.7 1.1 1
output:
0 Number of queries more than 4500 out of 2250
result:
wrong answer
Subtask #4:
score: 0
Wrong Answer
Test #10:
score: 0
Wrong Answer
time: 152ms
memory: 4236kb
input:
1 2000 5 100 0.01 1.00 0.10 1.70 0.00 1.50 5.0 1.20 1
output:
0 Number of queries more than 4000 out of 2000
result:
wrong answer
Subtask #5:
score: 0
Wrong Answer
Test #14:
score: 0
Wrong Answer
time: 134ms
memory: 4304kb
input:
1 1775 4 100 0.00 0.00 0.00 2.70 0.10 7.55 0.0 1.15 1
output:
0 Number of queries more than 3550 out of 1775
result:
wrong answer
Subtask #6:
score: 0
Wrong Answer
Test #20:
score: 0
Wrong Answer
time: 121ms
memory: 4240kb
input:
1 1625 5 100 0.00 0.00 0.00 3.00 0.00 1.00 0.0 3 1
output:
0 Number of queries more than 3250 out of 1625
result:
wrong answer