# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
247107 | errorgorn | 로카히아 유적 (FXCUP4_lokahia) | C++17 | 6 ms | 640 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 (chrono::system_clock::now().time_since_epoch().count());
const int trial=20; //test different startings
const int samples=15; //test different random places
vector<int> shuf(vector<int> v){
rep(x,0,sz(v)){
swap(v[x],v[rng()%(x+1)]);
}
return v;
}
int FindBase(int n){
if (n==1) return 1;
int best=-1;
int root;
vector<int> v;
rep(x,0,n) v.push_back(x);
shuf(v);
rep(x,0,min(trial,sz(v))){
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 (CollectRelics(node,temp)!=-1) curr++;
}
if (curr>best){
best=curr;
root=node;
}
}
int ans=-1;
int cnt=1;
rep(x,0,n) if (x!=root){
int temp=CollectRelics(root,x);
if (temp!=-1) cnt++,ans=max(ans,temp);
}
//cout<<ans<<" "<<cnt<<endl;
if (cnt>n/2) return ans;
else return -1;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |