QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#210099 | #5531. ICC | Camillus | Compile Error | / | / | C++20 | 4.5kb | 2023-10-11 01:29:33 | 2024-07-01 04:28:35 |
Judging History
你现在查看的是最新测评结果
- [2024-07-01 04:28:35]
- 管理员手动重测本题所有提交记录
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2023-10-11 01:29:34]
- 评测
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2023-10-11 01:29:33]
- 提交
answer
#include "bits/stdc++.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) {
cout << "? " << A.size();
for (int x : A) {
cout << " " << x;
}
cout << " " << B.size();
for (int x : B) {
cout << " " << x;
}
cout << endl;
string res;
cin >> res;
if (res == "YES") {
return true;
} else {
return false;
}
}
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);
}
Details
/usr/bin/ld: /tmp/ccpzcHQv.o: in function `main': answer.code:(.text.startup+0x0): multiple definition of `main'; /tmp/cc9Oso5t.o:implementer.cpp:(.text.startup+0x0): first defined here /usr/bin/ld: /tmp/cc9Oso5t.o: in function `main': implementer.cpp:(.text.startup+0x17): undefined reference to `run' collect2: error: ld returned 1 exit status