답안 #247334

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
247334 2020-07-11T08:48:40 Z dantoh000 로카히아 유적 (FXCUP4_lokahia) C++17
77 / 100
7 ms 896 KB
#include <bits/stdc++.h>
using namespace std;
#include "lokahia.h"
int Q[205][205];
const int LIM = 400;
int tq = 0;
int query(int i, int j){
    if (i == j) return Q[i][i] = i;
    else if (tq >= LIM) return -1;
    else if (Q[i][j] == -2) {
        tq++;
        return Q[i][j] = Q[j][i] = CollectRelics(i,j);
    }
    else return Q[i][j];
}
int FindBase(int N){
    for (int i = 0; i < N; i++) for (int j = 0; j < N; j++) Q[i][j] = -2;
    vector<int> good;
    for (int i = 0; i < N; i++) good.push_back(i);
    while (good.size() && tq <= LIM){
        sort(good.begin(),good.end());
        int cur = good[0];
        srand(time(NULL));
        random_shuffle(good.begin(),good.end());
        for (auto x : good){
            if (cur == x) continue;
            int q = query(cur,x);
            if (q != -1 && q > cur) cur = q;
        }
        int ct = 0;
        vector<int> bad;
        for (auto x : good){
            if (x == cur || query(x,cur) != -1) ct++;
            else bad.push_back(x);
            if (ct > N/2) break;
        }
        if (ct > N/2) return cur;
        good.clear();
        for (auto x : bad){
            good.push_back(x);
        }
        bad.clear();
    }
    return -1;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 640 KB Correct : C = 120
2 Correct 5 ms 768 KB Correct : C = 200
3 Partially correct 5 ms 640 KB Partially correct : C = 400
4 Partially correct 5 ms 768 KB Partially correct : C = 303
5 Partially correct 5 ms 768 KB Partially correct : C = 367
6 Correct 5 ms 512 KB Correct : C = 5
7 Correct 5 ms 768 KB Correct : C = 200
8 Correct 5 ms 768 KB Correct : C = 200
9 Partially correct 7 ms 896 KB Partially correct : C = 400
10 Correct 5 ms 640 KB Correct : C = 121
11 Partially correct 7 ms 896 KB Partially correct : C = 400
12 Correct 5 ms 640 KB Correct : C = 119
13 Correct 5 ms 640 KB Correct : C = 122
14 Partially correct 6 ms 768 KB Partially correct : C = 400
15 Correct 6 ms 768 KB Correct : C = 199
16 Correct 5 ms 512 KB Correct : C = 0
17 Partially correct 6 ms 640 KB Partially correct : C = 400
18 Partially correct 6 ms 768 KB Partially correct : C = 400
19 Correct 5 ms 640 KB Correct : C = 120
20 Partially correct 7 ms 768 KB Partially correct : C = 400
21 Partially correct 7 ms 768 KB Partially correct : C = 400
22 Partially correct 5 ms 640 KB Partially correct : C = 400
23 Partially correct 5 ms 640 KB Partially correct : C = 400
24 Correct 5 ms 640 KB Correct : C = 121
25 Correct 5 ms 768 KB Correct : C = 199
26 Correct 5 ms 768 KB Correct : C = 200
27 Partially correct 5 ms 768 KB Partially correct : C = 303