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 <iostream>
using namespace std;
const int M = 342;
int par[M], n;
bool adj[M][M], reported[M][M], found[M];
int F(int i) {
if(par[i] == i)
return i;
return par[i] = F(par[i]);
}
void U(int a, int b) {
par[F(a)] = F(b);
}
void add(int x, int y) {
U(x, y);
adj[x][y] = adj[y][x] = true;
if(!reported[x][y]) {
answer(x, y);
reported[x][y] = reported[y][x] = true;
}
}
void solve(int n, int l) {
for(int i = 1; i <= n; i++)
par[i] = i;
for(int i = 2; i <= n; i++) {
int k = 1, nxt = query(i, k);
while(k < n && nxt < i && F(i) != F(nxt)) {
add(i, nxt);
k++;
nxt = query(i, k);
}
}
}
# | 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... |