Submission #247349

# Submission time Handle Problem Language Result Execution time Memory
247349 2020-07-11T08:55:02 Z oolimry Lokahian Relics (FXCUP4_lokahia) C++17
0 / 100
34 ms 17256 KB
#include "lokahia.h"
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> ii;
 
int p[205];
int sz[205];
 
int findSet(int u){
  if(u == p[u]) return u;
  else return findSet(p[u]);
}
 
int SZ(int u){ return sz[findSet(u)]; }
 
void unionSet(int u, int P){
  u = findSet(u), P = findSet(P);
  p[u] = P;
  sz[P] += sz[u];
}
 
int FindBase(int N){
  srand(time(NULL));
  vector<int> v;
 
  if(N == 1){
	return 0;
  }
 
  for(int i = 0;i < N;i++) v.push_back(i);
 
  for(int i = 0;i < N;i++){
	p[i] = i;
	sz[i] = 1;
  }
 
  int cnt = 0;
  map<int,int> occur;
  
  vector<int> P;
  for(int i = N/4;i < N;i++){
	for(int j = 0;j < i*i;j++) P.push_back(i);  
  }
  
  while(cnt < 200){
	int a = P[rand() % P.size()], b = P[rand() % P.size()];
	if(a == b) continue;
	
	if((a+b)*2 < N) continue;
 
	cnt++;
	int x = CollectRelics(a,b);
	occur[x]++;
  }
 
  int best = 0;
  for(int i = 0;i < N;i++){
	if(occur[best] < occur[i]){
	  best = i;
	}
  }
 
  int total = 0;
  for(int i = 0;i < N;i++){
	if(i == best){
	  total++;
	  continue;
	}
 
	if(CollectRelics(i,best) != -1) total++;
  }
 
  //cout << best;
  if(total > (N/2)) return best;
  //assert(false);
  //cout << best;
  return -1;
}
# Verdict Execution time Memory Grader output
1 Partially correct 30 ms 17256 KB Partially correct : C = 398
2 Correct 6 ms 512 KB Correct : C = 204
3 Partially correct 10 ms 4848 KB Partially correct : C = 318
4 Partially correct 29 ms 17256 KB Partially correct : C = 399
5 Incorrect 32 ms 17248 KB Wrong
6 Partially correct 11 ms 4880 KB Partially correct : C = 319
7 Partially correct 31 ms 17244 KB Partially correct : C = 399
8 Partially correct 34 ms 17256 KB Partially correct : C = 399
9 Partially correct 28 ms 17256 KB Partially correct : C = 399
10 Partially correct 11 ms 4848 KB Partially correct : C = 319
11 Correct 5 ms 512 KB Correct : C = 0
12 Partially correct 28 ms 17256 KB Partially correct : C = 398
13 Partially correct 30 ms 17232 KB Partially correct : C = 398
14 Partially correct 12 ms 4848 KB Partially correct : C = 318
15 Partially correct 28 ms 17256 KB Partially correct : C = 399
16 Partially correct 10 ms 4848 KB Partially correct : C = 319
17 Partially correct 10 ms 4848 KB Partially correct : C = 318
18 Partially correct 28 ms 17256 KB Partially correct : C = 399
19 Partially correct 29 ms 17256 KB Partially correct : C = 399
20 Partially correct 10 ms 4848 KB Partially correct : C = 318
21 Incorrect 31 ms 17244 KB Wrong
22 Partially correct 12 ms 4848 KB Partially correct : C = 318
23 Partially correct 34 ms 17256 KB Partially correct : C = 398
24 Partially correct 11 ms 4848 KB Partially correct : C = 319
25 Partially correct 29 ms 17256 KB Partially correct : C = 398
26 Partially correct 11 ms 4848 KB Partially correct : C = 319
27 Partially correct 30 ms 17256 KB Partially correct : C = 398