#include <bits/stdc++.h>
#include "lokahia.h"
using namespace std;
int p[210];
int visit[210][210];
int num[210];
int findset(int i){
return p[i]==i?p[i]:p[i]=findset(p[i]);
}
int FindBase(int N){
srand(3082);
int counter = 0;
for (int i = 0; i < N; i++) p[i] = i;
int fail = 0;
while (counter < 200){
int a = rand()%N,b = rand()%N;
if (fail > 10000) break;
fail++;
if (a == b) continue;
if (visit[findset(a)][findset(b)]) continue;
if (findset(a) == findset(b)) continue;
fail = 0;
counter++;
int x = findset(a),y = findset(b);
visit[x][y] = visit[y][x] = 1;
int temp = CollectRelics(a,b);
if (temp != -1) {
for (int i = 0; i < N; i++){
visit[temp][i] = visit[i][temp] = max(visit[temp][i],max(visit[x][i],visit[y][i]));
}
p[x] = temp;
p[y] = temp;
}
}
for (int i = 0; i < N; i++){
num[findset(i)]++;
}
int maxi = 0,cur = -1;
for (int i = 0; i < N; i++){
if (num[i] >= maxi){
maxi = num[i];
cur = i;
}
}
int tot = 0;
for (int i = 0; i < N; i++){
if (findset(i)== cur) tot++;
else tot += CollectRelics(i,cur)!=-1;
}
if (tot > N/2) return cur;
return -1;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
5 ms |
768 KB |
Partially correct : C = 327 |
2 |
Correct |
5 ms |
640 KB |
Correct : C = 264 |
3 |
Partially correct |
5 ms |
768 KB |
Partially correct : C = 399 |
4 |
Partially correct |
5 ms |
768 KB |
Partially correct : C = 319 |
5 |
Correct |
6 ms |
768 KB |
Correct : C = 154 |
6 |
Correct |
5 ms |
512 KB |
Correct : C = 3 |
7 |
Correct |
5 ms |
640 KB |
Correct : C = 265 |
8 |
Partially correct |
5 ms |
768 KB |
Partially correct : C = 317 |
9 |
Correct |
5 ms |
640 KB |
Correct : C = 267 |
10 |
Correct |
5 ms |
640 KB |
Correct : C = 253 |
11 |
Correct |
5 ms |
640 KB |
Correct : C = 190 |
12 |
Correct |
5 ms |
640 KB |
Correct : C = 274 |
13 |
Partially correct |
5 ms |
768 KB |
Partially correct : C = 322 |
14 |
Correct |
5 ms |
640 KB |
Correct : C = 88 |
15 |
Partially correct |
5 ms |
768 KB |
Partially correct : C = 338 |
16 |
Partially correct |
5 ms |
640 KB |
Partially correct : C = 318 |
17 |
Partially correct |
5 ms |
768 KB |
Partially correct : C = 385 |
18 |
Partially correct |
5 ms |
768 KB |
Partially correct : C = 378 |
19 |
Correct |
5 ms |
768 KB |
Correct : C = 145 |
20 |
Partially correct |
6 ms |
768 KB |
Partially correct : C = 342 |
21 |
Partially correct |
5 ms |
768 KB |
Partially correct : C = 324 |
22 |
Partially correct |
5 ms |
768 KB |
Partially correct : C = 311 |
23 |
Correct |
5 ms |
640 KB |
Correct : C = 93 |
24 |
Partially correct |
5 ms |
640 KB |
Partially correct : C = 319 |
25 |
Correct |
5 ms |
512 KB |
Correct : C = 0 |
26 |
Partially correct |
5 ms |
768 KB |
Partially correct : C = 398 |
27 |
Partially correct |
5 ms |
768 KB |
Partially correct : C = 322 |