# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
379470 | oolimry | Lokahian Relics (FXCUP4_lokahia) | C++17 | 465 ms | 748 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "lokahia.h"
#include <bits/stdc++.h>
using namespace std;
#define sz(x) (int) (x).size()
#define all(x) (x).begin(), (x).end()
#define show(x) cerr << #x << " is " << x << endl;
#define show2(x, y) cerr << #x << " is " << x << "," << #y << " is " << y << endl;
typedef long long lint;
typedef pair<lint,lint> ii;
int p[205];
int SZ[205];
int findSet(int u){
if(u == p[u]) return u;
else return p[u] = findSet(p[u]);
}
void unionSet(int u, int v){
u = findSet(u);
v = findSet(v);
if(u == v) return;
p[u] = v;
SZ[v] += SZ[u];
}
mt19937 rng(time(NULL));
int FindBase(int n){
int qrylimit = 600;
for(int i = 0;i <= n;i++) p[i] = i, SZ[i] = 1;
int total = 10000000;
while(qrylimit > 0 and total > 0){
int a = rng() % n, b = rng() % n;
total--;
if(a == b) continue;
if(findSet(a) == findSet(b)) continue;
int x = CollectRelics(a,b); qrylimit--;
if(x == -1) continue;
if(a != x and b != x){
unionSet(a,x);
unionSet(b,x);
}
else if(x == a){
unionSet(b,a);
}
else unionSet(a,b);
cout << a << " " << b << " " << x << "\n";
}
for(int i = 0;i < n;i++){
if(SZ[i] > n/2) return i;
}
return -1;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |