This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "icc.h"
#include <bits/stdc++.h>
using namespace std;
// int query(int size_a, int size_b, int a[], int b[]);
// void setRoad(int a, int b);
const int MAXN = 100;
vector<int> adj[MAXN+1];
bool vis[MAXN+1];
void dfs(int v) {
vis[v] = true;
for (int viz : adj[v]) {
if (!vis[viz]) dfs(viz);
}
}
int do_query(vector<int> a, vector<int> b) {
int tmp[MAXN], tmp2[MAXN];
for (int i=0; i<(int)a.size(); i++) tmp[i] = a[i];
for (int i=0; i<(int)b.size(); i++) tmp2[i] = b[i];
return query((int)a.size(), (int)b.size(), tmp, tmp2);
}
void run(int N) {
int n = N;
for (int e=0; e<n-1; e++) {
vector<int> src(n);
for (int i=0; i<n; i++) src[i] = i+1;
random_shuffle(src.begin(), src.end());
int a = 0; vector<int> dest;
for (int v : src) {
dfs(v);
for (int i=1; i<=n; i++) {
if (!vis[i]) dest.push_back(i);
}
for (int i=1; i<=n; i++) vis[i] = false;
a = v;
if (do_query(vector<int> (1, v), dest)) break;
dest.clear();
}
random_shuffle(dest.begin(), dest.end());
for (int b : dest) {
if (do_query(vector<int>(1, a), vector<int> (1, b))) {
setRoad(a, b);
break;
}
}
}
}
// int main() {
// return 0;
// }
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |