답안 #247289

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
247289 2020-07-11T08:38:02 Z dwsc 로카히아 유적 (FXCUP4_lokahia) C++17
51 / 100
7 ms 896 KB
#include <bits/stdc++.h>
#include "lokahia.h"
using namespace std;
int p[210];
int visit[210][210];
int num[210];
int findset(int i){
    return p[i]==i?p[i]:p[i]=findset(p[i]);
}
int FindBase(int N){
    srand(3082);
	int counter = 0;
	for (int i = 0; i < N; i++) p[i] = i;
	int fail = 0;
	while (counter < 300){
        int a = rand()%N,b = rand()%N;
        if (fail > 1000) break;
        fail++;
        if (a == b) continue;
        if (visit[a][b]) continue;
        if (findset(a) == findset(b)) continue;
        fail = 0;
        counter++;
        visit[a][b] = visit[b][a] = 1;
        int temp = CollectRelics(a,b);
        if (temp != -1) {
            p[findset(a)] = temp;
            p[findset(b)] = temp;
        }
	}
    for (int i = 0; i < N; i++){
        num[findset(i)]++;
    }
    int maxi = 0,cur = -1;
    for (int i = 0; i < N; i++){
        if (num[i] >= maxi){
            maxi = num[i];
            cur = i;
        }
    }
    int tot = 0;
    for (int i = 0; i < N; i++){
        if (findset(i)== cur) tot++;
        else tot += CollectRelics(i,cur)!=-1;
    }
    if (tot > N/2) return cur;
    return -1;
}
# 결과 실행 시간 메모리 Grader output
1 Partially correct 5 ms 768 KB Partially correct : C = 404
2 Partially correct 5 ms 640 KB Partially correct : C = 364
3 Partially correct 6 ms 896 KB Partially correct : C = 418
4 Partially correct 5 ms 640 KB Partially correct : C = 365
5 Partially correct 6 ms 768 KB Partially correct : C = 498
6 Correct 5 ms 640 KB Correct : C = 93
7 Partially correct 5 ms 768 KB Partially correct : C = 473
8 Partially correct 5 ms 640 KB Partially correct : C = 361
9 Partially correct 6 ms 768 KB Partially correct : C = 424
10 Partially correct 5 ms 768 KB Partially correct : C = 412
11 Partially correct 5 ms 768 KB Partially correct : C = 499
12 Partially correct 6 ms 896 KB Partially correct : C = 477
13 Partially correct 6 ms 896 KB Partially correct : C = 412
14 Partially correct 5 ms 640 KB Partially correct : C = 419
15 Partially correct 5 ms 640 KB Partially correct : C = 365
16 Correct 6 ms 512 KB Correct : C = 0
17 Partially correct 5 ms 640 KB Partially correct : C = 360
18 Correct 5 ms 768 KB Correct : C = 154
19 Partially correct 5 ms 640 KB Partially correct : C = 355
20 Partially correct 7 ms 768 KB Partially correct : C = 425
21 Correct 5 ms 512 KB Correct : C = 3
22 Partially correct 5 ms 768 KB Partially correct : C = 415
23 Partially correct 5 ms 640 KB Partially correct : C = 418
24 Correct 5 ms 768 KB Correct : C = 145
25 Partially correct 6 ms 768 KB Partially correct : C = 411
26 Correct 5 ms 640 KB Correct : C = 88
27 Partially correct 5 ms 768 KB Partially correct : C = 400