| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1370449 | pcheloveks | Voltage 2 (JOI26_voltage) | C++20 | 43 ms | 948 KiB |
#include "voltage.h"
#include <bits/stdc++.h>
using namespace std;
bool checkIsLeaf(int val, int n, vector < int >& s) {
vector < int > a(n, 1), b(n, 0);
for(auto x: s) {
a[x] = 0;
}
a[val] = 0;
int tmp = query(a, b);
return (query(a, b) == 0);
}
bool solve(int N, int M) {
vector < int > s;
vector < bool > inSet(N, false);
vector < pair < int, int > > res;
queue < int > q;
for(int i = 0; i < N; i++) q.push(i);
while(!q.empty()) {
int val = q.front();
q.pop();
if(inSet[val]) continue;
if(checkIsLeaf(val, N, s)) {
vector < int > childs;
vector < bool > isChild(N, false);
while(true) {
vector < int > a;
for(int j = 0; j < N; j++) {
if(!inSet[j] && !isChild[j] && j != val) a.push_back(j);
}
int L = -1, R = a.size() + 1;
while(R - L > 1) {
int mid = (L + R) >> 1;
vector < int > v1(N), v2(N);
for(auto x: s) {
v1[x] = 0; v2[x] = 0;
}
for(auto x: childs) {
v1[x] = 1; v2[x] = 1;
}
v1[val] = 1; v2[val] = 0;
for(int i = 0; i < mid; i++) {
v1[a[i]] = 1; v2[a[i]] = 1;
}
for(int i = mid; i < a.size(); i++) {
v1[a[i]] = 0; v2[a[i]] = 0;
}
if(query(v1, v2) == 0) R = mid;
else L = mid;
}
if(R == 0) break;
childs.push_back(a[R - 1]);
isChild[a[R - 1]] = true;
}
for(auto x: childs) {
q.push(x);
res.push_back({val, x});
}
s.push_back(val);
inSet[val] = true;
}
}
if(s.size() != N) return false;
for(auto x: res) answer(x.first, x.second);
return true;
}
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
