#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(8052);
int counter = 0;
for (int i = 0; i < N; i++) p[i] = i;
int fail = 0;
while (counter < 400){
int a = rand()%N,b = rand()%N;
if (fail > 1000) break;
fail++;
if (a == b) continue;
if (visit[a][b]) continue;
if (findset(a) == findset(b)) continue;
fail = 0;
counter++;
visit[a][b] = visit[b][a] = 1;
int temp = CollectRelics(a,b);
if (temp != -1) {
p[findset(a)] = temp;
p[findset(b)] = 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 = 1;
for (int i = 0; i < N; i++){
if (i == cur) continue;
tot += CollectRelics(i,cur)!=-1;
}
if (tot > N/2) return cur;
return -1;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
640 KB |
Correct : C = 210 |
2 |
Partially correct |
5 ms |
768 KB |
Partially correct : C = 599 |
3 |
Correct |
5 ms |
512 KB |
Correct : C = 0 |
4 |
Partially correct |
5 ms |
768 KB |
Partially correct : C = 599 |
5 |
Partially correct |
5 ms |
640 KB |
Partially correct : C = 519 |
6 |
Correct |
5 ms |
640 KB |
Correct : C = 205 |
7 |
Partially correct |
5 ms |
768 KB |
Partially correct : C = 598 |
8 |
Partially correct |
5 ms |
768 KB |
Partially correct : C = 351 |
9 |
Partially correct |
6 ms |
768 KB |
Partially correct : C = 598 |
10 |
Partially correct |
5 ms |
768 KB |
Partially correct : C = 598 |
11 |
Partially correct |
5 ms |
640 KB |
Partially correct : C = 518 |
12 |
Partially correct |
6 ms |
896 KB |
Partially correct : C = 599 |
13 |
Partially correct |
6 ms |
768 KB |
Partially correct : C = 598 |
14 |
Partially correct |
5 ms |
640 KB |
Partially correct : C = 519 |
15 |
Partially correct |
5 ms |
640 KB |
Partially correct : C = 518 |
16 |
Partially correct |
5 ms |
768 KB |
Partially correct : C = 345 |
17 |
Partially correct |
6 ms |
768 KB |
Partially correct : C = 598 |
18 |
Incorrect |
5 ms |
640 KB |
Wrong |
19 |
Partially correct |
5 ms |
896 KB |
Partially correct : C = 599 |
20 |
Partially correct |
6 ms |
768 KB |
Partially correct : C = 599 |
21 |
Correct |
5 ms |
512 KB |
Correct : C = 7 |
22 |
Partially correct |
5 ms |
640 KB |
Partially correct : C = 519 |
23 |
Partially correct |
5 ms |
896 KB |
Partially correct : C = 599 |
24 |
Partially correct |
5 ms |
640 KB |
Partially correct : C = 519 |
25 |
Partially correct |
5 ms |
768 KB |
Partially correct : C = 599 |
26 |
Partially correct |
6 ms |
768 KB |
Partially correct : C = 598 |
27 |
Partially correct |
5 ms |
640 KB |
Partially correct : C = 518 |