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 "island.h"
#include <algorithm>
#include <iostream>
using namespace std;
const int M = 342;
int pre[M], n, l;
bool adj[M][M], reported[M][M], found[M];
void add(int x, int y) {
adj[x][y] = adj[y][x] = true;
pre[x] = max(pre[x], y);
pre[y] = max(pre[y], x);
if(!reported[x][y]) {
answer(x, y);
reported[x][y] = reported[y][x] = true;
}
}
void find(int i) {
if(found[i]) return;
found[i] = true;
int k = 1;
while(k < n) {
int nxt = query(i, k);
add(i, nxt);
if(nxt == pre[i])
k = n;
k++;
}
}
void solve(int nb, int l) {
n = nb;
for(int i = 1; i <= n; i++)
pre[i] = -1;
for(int i = n; i > 0; i--) {
if(pre[i] == -1) {
int k = 1;
while(k < n) {
int nxt = query(i, k);
bool ok = true;
for(int j = 1; j <= n; j++)
if(adj[i][j] && adj[j][nxt])
ok = false;
if(ok) {
add(i, nxt);
find(nxt);
} else {
k = n;
}
k++;
}
} else {
find(i);
}
}
}
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |