# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
58691 |
2018-07-18T21:38:05 Z |
Mamnoon_Siam |
ICC (CEOI16_icc) |
C++17 |
|
213 ms |
800 KB |
#include "icc.h"
#include <bits/stdc++.h>
using namespace std;
namespace {
const int maxn = 105;
int n;
int ok[maxn][maxn];
int par[maxn];
}
int find(int u) {
return par[u] == u ? u : par[u] = find(par[u]);
}
void unite(int u, int v) {
u = find(u), v = find(v);
if(u == v) return;
if(rand() % 2) swap(u, v);
par[u] = v;
}
void addedge(int u, int v) {
ok[u][v] = ok[v][u] = 1;
setRoad(u, v);
unite(u, v);
}
int ask(vector<int> x, vector<int> y) {
int tmp = query((int)x.size(), (int)y.size(), x.data(), y.data());
// cout << "[Query]" << endl;
// cout << "a = {"; for(int i : x) cout << i << ","; cout << "}" << endl;
// cout << "b = {"; for(int i : y) cout << i << ","; cout << "}" << endl;
// cout << "tmp = " << tmp << endl;
return tmp;
}
int chex(int u) {
vector<int> a(1, u), b;
for(int i = 1; i <= n; i++) {
if(i != u and !ok[u][i]) {
b.push_back(i);
}
}
if(b.empty()) return 0;
return ask(a, b);
}
int find_another(int u) {
vector<int> vec(n);
iota(vec.begin(), vec.end(), 1);
random_shuffle(vec.begin(), vec.end(), [](int i){return rand() % i;});
for(int i : vec) {
if(i != u and !ok[u][i] /*and find(i) != find(u)*/) {
if(ask(vector<int>(1, u), vector<int>(1, i))) {
return i;
}
}
} assert(false);
}
void run(int N) {
srand(time(0));
memset(ok, 0, sizeof ok);
n = N;
int rnd = n - 1;
while(rnd--) {
int u = 0;
vector<int> vec(n);
iota(vec.begin(), vec.end(), 1);
random_shuffle(vec.begin(), vec.end(), [](int i){return rand() % i;});
for(int i : vec)
if(chex(i)) { u = i; break; }
int v = find_another(u);
addedge(u, v);
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
18 ms |
504 KB |
Wrong road! |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
37 ms |
612 KB |
Wrong road! |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
35 ms |
648 KB |
Wrong road! |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
123 ms |
728 KB |
Wrong road! |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
213 ms |
756 KB |
Wrong road! |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
143 ms |
800 KB |
Wrong road! |
2 |
Halted |
0 ms |
0 KB |
- |