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 <bits/stdc++.h>
#include "park.h"
using namespace std;
static int Place[1400];
int n;
void solve1() {
for (int i = 0; i < n; i++) {
for (int j = i + 1; j < n; j++) {
Place[i] = Place[j] = 1;
if (Ask(i, j, Place)) {
Answer(i, j);
}
Place[i] = Place[j] = 0;
}
}
}
int used[1400];
int deg[1400];
void solve2() {
vector < int > vec(n);
iota(vec.begin(), vec.end(), 0);
random_shuffle(vec.begin(), vec.end());
for (int i = 0; i < n; i++) {
if (deg[vec[i]] > 1) continue;
for (int j = 0; j < n; j++) {
if (used[vec[j]]) continue;
Place[vec[i]] = Place[vec[j]] = 1;
if (Ask(vec[i], vec[j], Place)) {
Answer(vec[i], vec[j]);
deg[vec[i]]++;
deg[vec[j]]++;
used[vec[j]] = 1;
used[vec[i]] = 1;
}
Place[vec[i]] = Place[vec[j]] = 0;
}
}
}
void Detect(int T, int N) {
srand(time(0));
n = N;
if (T == 1) {
solve1();
} else if (T == 2) {
solve2();
} else {
}
}
# | 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... |