QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#210104 | #5531. ICC | Camillus | Compile Error | / | / | C++20 | 4.2kb | 2023-10-11 01:32:10 | 2024-07-01 04:28:38 |
Judging History
你现在查看的是最新测评结果
- [2024-07-01 04:28:38]
- 管理员手动重测本题所有提交记录
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2023-10-11 01:32:10]
- 评测
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2023-10-11 01:32:10]
- 提交
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();
}
};
random_device rd;
mt19937 rnd(rd());
int rand(int n) {
return rnd() % n;
}
int rand(int l, int r) {
return l + rand(r - l + 1);
}
vector<int> low_half(const vector<int> &A) {
size_t x = A.size() >> 1;
return vector<int>(A.begin(), A.begin() + x);
}
vector<int> top_half(const vector<int> &A) {
size_t x = A.size() >> 1;
return vector<int>(A.begin() + x, A.end());
}
bool query(const vector<int> &A, const vector<int> &B) {
return query(A.size(), B.size(), A.data(), B.data());
}
//void setRoad(int u, int v) {
// cout << "! " << u << " " << v << endl;
//}
void run(int n) {
dsu Q(n + 1);
auto loop = [&]() {
map<int, vector<int>> A;
for (int u = 1; u <= n; u++) {
A[Q.get(u)].push_back(u);
}
vector<vector<int>> B;
B.reserve(A.size());
for (const auto &[a, b] : A) {
B.push_back(b);
}
int m = (int)B.size();
auto get = [&](const vector<int> &p) -> vector<int> {
vector<int> Q;
for (int i : p) {
Q.insert(Q.end(), B[i].begin(), B[i].end());
}
return Q;
};
int x = 0;
vector<int> x0, x1;
for (int i = 0; i <= __lg(m); i++) {
vector<int> p0, p1;
for (int j = 0; j < m; j++) {
if (bitset<32>(j)[i] == 0) {
p0.push_back(j);
} else {
p1.push_back(j);
}
}
if (query(get(p0), get(p1))) {
x1.push_back(i);
x ^= 1 << i;
} else {
x0.push_back(i);
}
}
int u = 0;
for (int i : x0) {
vector<int> p0, p1;
for (int j = 0; j < m; j++) {
if (bitset<32>(j)[i] == 1 && bitset<32>(j)[x1.front()] == 0) {
p0.push_back(j);
}
if (bitset<32>(j)[i] == 1 && bitset<32>(j)[x1.front()] == 1) {
p1.push_back(j);
}
}
if (query(get(p0), get(p1))) {
u |= 1 << i;
}
}
for (int i : x1) {
if (i == x1.front()) {
continue;
}
vector<int> p0, p1;
for (int j = 0; j < m; j++) {
if (bitset<32>(j)[i] == 0 && bitset<32>(j)[x1.front()] == 0) {
p0.push_back(j);
}
if (bitset<32>(j)[i] == 1 && bitset<32>(j)[x1.front()] == 1) {
p1.push_back(j);
}
}
if (!query(get(p0), get(p1))) {
u ^= 1 << i;
}
}
int v = x ^ u;
auto a = get({u});
auto b = get({v});
while (b.size() != 1) {
if (query(a, low_half(b))) {
b = low_half(b);
} else {
b = top_half(b);
}
}
while (a.size() != 1) {
if (query(low_half(a), b)) {
a = low_half(a);
} else {
a = top_half(a);
}
}
setRoad(a.front(), b.front());
Q.join(a.front(), b.front());
};
for (int i = 0; i < n - 1; i++) {
loop();
}
}
//
//int main() {
// int n;
// cin >> n;
// run(n);
//}
详细
answer.code: In function ‘bool query(const std::vector<int>&, const std::vector<int>&)’: answer.code:63:44: error: invalid conversion from ‘const int*’ to ‘int*’ [-fpermissive] 63 | return query(A.size(), B.size(), A.data(), B.data()); | ~~~~~~^~ | | | const int* In file included from answer.code:2: icc.h:10:30: note: initializing argument 3 of ‘int query(int, int, int*, int*)’ 10 | int query(int a, int b, int *A, int *B); | ~~~~~^ answer.code:63:54: error: invalid conversion from ‘const int*’ to ‘int*’ [-fpermissive] 63 | return query(A.size(), B.size(), A.data(), B.data()); | ~~~~~~^~ | | | const int* icc.h:10:38: note: initializing argument 4 of ‘int query(int, int, int*, int*)’ 10 | int query(int a, int b, int *A, int *B); | ~~~~~^