# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
64099 | Just_Solve_The_Problem | popa (BOI18_popa) | C++11 | 106 ms | 788 KiB |
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 "popa.h"
#include <bits/stdc++.h>
#define pb push_back
#define pii pair < int, int >
#define fr first
#define sc second
#define mk make_pair
using namespace std;
int tab[123][123];
pii ar[123];
int used[123];
int solve(int n, int left[], int right[]) {
assert(n == 100);
for (int i = 0; i < n; i++)
left[i] = right[i] = -1;
int root = 0;
int mx = 0;
for (int i = 0; i < n; i++) {
int len = 0;
for (int j = 0; j < n; j++) {
if (j == i) continue;
tab[i][j] = query(i, i, j, j);
if (tab[i][j]) {
len++;
}
}
ar[i] = mk(len, i);
}
sort(ar, ar + n);
reverse(ar, ar + n);
root = ar[0].sc;
queue < int > q;
q.push(root);
used[root] = 1;
while (!q.empty()) {
int v = q.front();
q.pop();
int mx = -1;
for (int i = 0; i < n; i++) {
if (used[ar[i].sc]) continue;
if (tab[v][ar[i].sc]) {
mx = ar[i].sc;
break;
}
}
if (mx != -1) {
used[mx] = 1;
left[v] = mx;
q.push(mx);
}
mx = -1;
for (int i = 0; i < n; i++) {
if (used[ar[i].sc]) continue;
if (tab[v][ar[i].sc]) {
mx = ar[i].sc;
break;
}
}
if (mx != -1) {
used[mx] = 1;
right[v] = mx;
q.push(mx);
}
}
return root;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |