답안 #247150

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
247150 2020-07-11T06:50:55 Z errorgorn 로카히아 유적 (FXCUP4_lokahia) C++17
0 / 100
6 ms 768 KB
#include <bits/stdc++.h>
#include "lokahia.h"
using namespace std;
 
#define ll long long
#define fi first
#define se second 

#define rep(x,s,e) for (auto x=s-(s>e);x!=e-(s>e);(s<e?x++:x--))
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
mt19937 rng (177013);

const int trial=20; //test different startings
const int samples=10; //test different random places
const int pass=6;

int memo[205][205];
int get(int i,int j){
	if (memo[i][j]!=-1) return memo[i][j];
	
	return memo[i][j]=memo[j][i]=CollectRelics(i,j);
}


vector<int> shuf(vector<int> v){
	rep(x,0,sz(v)){
		swap(v[x],v[rng()%(x+1)]);
	}
	
	return v;
}

bool vis[205];

int FindBase(int n){
	memset(memo,-1,sizeof(memo));
	
	if (n<=20){ //maybe
		rep(root,0,n){
			int cnt=1;
			int ans=-1;
			rep(x,0,n) if (x!=root){
				int temp=get(root,x);
		
				if (temp!=-1) cnt++,ans=max(ans,temp);
			}
			
			if (cnt>n/2) return ans;
		}
		
		return -1;
	}
	
	vector<int> v;
	rep(x,0,n) v.push_back(x);
	
	v=shuf(v);
	
	vector<int> cand;
	
	rep(x,0,trial){
		int node=v[x];
		int curr=0;
		rep(zzz,0,samples){
			int temp;
			
			do{
				temp=rng()%n;
			} while (temp==node);
			
			//cout<<"debug: "<<node<<" "<<temp<<endl;
			if (get(node,temp)!=-1) curr++;
			
		}
		
		if (curr>=pass){
			cand.push_back(node);
		}
	}
	
	for (auto &it:cand){
		if (vis[it]) continue;
		vis[it]=true;
		
		int cnt=1;
		int ans=-1;
		
		rep(x,0,n) if (!vis[x]){
			int temp=get(it,x);
			
			if (temp!=-1){
				ans=max(ans,temp);
				cnt++;
				vis[x]=true;
			}
		}
		
		//cout<<it<<" "<<cnt<<" "<<ans<<endl;
		
		if (cnt>n/2) return ans;
	}
	
	
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 768 KB Wrong
2 Incorrect 6 ms 768 KB Wrong
3 Incorrect 5 ms 768 KB Wrong
4 Partially correct 5 ms 768 KB Partially correct : C = 311
5 Partially correct 5 ms 768 KB Partially correct : C = 386
6 Incorrect 5 ms 640 KB Wrong
7 Correct 5 ms 640 KB Correct : C = 4
8 Incorrect 5 ms 768 KB Wrong
9 Partially correct 5 ms 768 KB Partially correct : C = 380
10 Incorrect 5 ms 768 KB Wrong
11 Incorrect 5 ms 768 KB Wrong
12 Partially correct 5 ms 768 KB Partially correct : C = 391
13 Partially correct 5 ms 768 KB Partially correct : C = 309
14 Incorrect 5 ms 768 KB Wrong
15 Partially correct 5 ms 768 KB Partially correct : C = 382
16 Incorrect 5 ms 768 KB Wrong
17 Partially correct 5 ms 768 KB Partially correct : C = 389
18 Partially correct 5 ms 768 KB Partially correct : C = 389
19 Incorrect 6 ms 768 KB Wrong
20 Partially correct 5 ms 768 KB Partially correct : C = 392
21 Partially correct 5 ms 768 KB Partially correct : C = 312
22 Partially correct 5 ms 768 KB Partially correct : C = 357
23 Partially correct 5 ms 768 KB Partially correct : C = 391
24 Partially correct 5 ms 768 KB Partially correct : C = 301
25 Correct 5 ms 768 KB Correct : C = 300
26 Incorrect 5 ms 768 KB Wrong
27 Incorrect 5 ms 768 KB Wrong