#include"lokahia.h"
#include<cstring>
#include<vector>
#include<ctime>
#include<algorithm>
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef pair<int,int>pi;
typedef pair<ll,ll>pl;
const ll inf=1e18;
int pa[205],sz[205];
int par(int x)
{
if(pa[x]==-1)
return x;
return pa[x]=par(pa[x]);
}
int C[205];
vector<int>v;
bool chk[205][205];
int cnt;
int FindBase(int N)
{
if(N==1)
return 0;
int i;
for(i=0;i<N;i++)
v.eb(i);
memset(pa,-1,sizeof pa);
fill(sz,sz+205,1);
for(i=0;i<600&&cnt<500000&&v.size()>1;i++,cnt++)
{
int n=rand()%v.size();
int j=n;
while(j==n)
j=rand()%v.size();
n=v[n];
j=v[j];
if(chk[n][j])
{
i--;
continue;
}
chk[n][j]=true;
int t=CollectRelics(n,j);
if(t!=-1)
{
t=par(t);
if(n!=t)
{
vector<int>::iterator it=v.begin();
while(it!=v.end())
{
if(*it==n)
break;
it++;
}
v.erase(it);
pa[n]=t;
sz[t]+=sz[n];
}
n=j;
if(n!=t)
{
vector<int>::iterator it=v.begin();
while(it!=v.end())
{
if(*it==n)
break;
it++;
}
v.erase(it);
pa[n]=t;
sz[t]+=sz[n];
}
}
}
for(i=0;i<N;i++)
if(pa[i]==-1&&sz[i]>=N/2)
break;
if(i>=N)
return-1;
return sz[i];
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
9 ms |
640 KB |
Partially correct : C = 600 |
2 |
Incorrect |
6 ms |
640 KB |
Wrong |
3 |
Incorrect |
23 ms |
640 KB |
Wrong |
4 |
Partially correct |
6 ms |
640 KB |
Partially correct : C = 600 |
5 |
Partially correct |
6 ms |
640 KB |
Partially correct : C = 600 |
6 |
Incorrect |
10 ms |
512 KB |
Wrong |
7 |
Partially correct |
6 ms |
640 KB |
Partially correct : C = 600 |
8 |
Incorrect |
6 ms |
640 KB |
Wrong |
9 |
Incorrect |
36 ms |
640 KB |
Wrong |
10 |
Incorrect |
7 ms |
640 KB |
Wrong |
11 |
Incorrect |
22 ms |
640 KB |
Wrong |
12 |
Incorrect |
6 ms |
640 KB |
Wrong |
13 |
Incorrect |
23 ms |
640 KB |
Wrong |
14 |
Incorrect |
7 ms |
640 KB |
Wrong |
15 |
Incorrect |
6 ms |
640 KB |
Wrong |
16 |
Partially correct |
6 ms |
640 KB |
Partially correct : C = 600 |
17 |
Incorrect |
36 ms |
640 KB |
Wrong |
18 |
Incorrect |
36 ms |
640 KB |
Wrong |
19 |
Partially correct |
6 ms |
640 KB |
Partially correct : C = 600 |
20 |
Incorrect |
6 ms |
640 KB |
Wrong |
21 |
Incorrect |
10 ms |
640 KB |
Wrong |
22 |
Incorrect |
23 ms |
640 KB |
Wrong |
23 |
Partially correct |
14 ms |
640 KB |
Partially correct : C = 600 |
24 |
Correct |
6 ms |
512 KB |
Correct : C = 0 |
25 |
Partially correct |
6 ms |
640 KB |
Partially correct : C = 600 |
26 |
Incorrect |
43 ms |
640 KB |
Wrong |
27 |
Partially correct |
6 ms |
640 KB |
Partially correct : C = 600 |