답안 #150486

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
150486 2019-09-01T08:30:35 Z mit한의대지망생(#3602, TAMREF, imeimi2000, suzy) 로카히아 유적 (FXCUP4_lokahia) C++17
0 / 100
7 ms 640 KB
#include "lokahia.h"
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cstdlib>

using namespace std;

int FindBase(int n) {
    if (n <= 2) return 0;
    int ord[201];
    int out[201];
    int same[201];
    int same1[201];
    for (int i = 0; i < n; ++i) ord[i] = i;
    srand(0x525252);
    random_shuffle(ord, ord + n);
    vector<int> L;
    L.push_back(0);
    same[0] = 1;
    out[0] = ord[0];
    int sum = 1, c = -1;
    for (int i = 1; i < n; ++i) {
        int ret = CollectRelics(ord[L.back()], ord[i]);
        if (ret != -1) {
            out[L.back()] = out[i] = ret;
            ++sum;
            same[i] = 1;
        }
        else {
            out[i] = ord[i];
            same[i] = 0;
            --sum;
        }
        if (sum == 0) {
            same[++i] = 1;
            out[i] = ord[i];
            if (i <= n) L.push_back(i);
            ++sum;
        }
    }
    vector<int> C;
    int del = sum;
    for (int i = 0; i < (int)L.size() - 1; ++i) {
        int a = L[i], b = L[i + 1];
        int ret = CollectRelics(ord[a], ord[L.back()]);
        if (ret != -1) {
            out[a] = out[L.back()] = ret;
            for (int j = a; j < b; ++j) same1[j] = same[j];
            continue;
        }
        for (int j = a; j < b; ++j) {
            if (same[j]) {
                same1[j] = 0;
                continue;
            }
            int ret = CollectRelics(ord[L.back()], ord[j]);
            if (ret != -1) {
                out[L.back()] = out[j] = ret;
            }
            else if ((del -= 2) < -1) break;
        }
        if (del < -1) break;
    }
    if (sum > 1 && del < -1) return -1;
    if (del > -2) return out[L.back()];
    if (c == -1) return -1;
    del = -sum;
    for (int i = 0; i < (int)L.size() - 1; ++i) {
        int a = L[i], b = L[i + 1];
        int ret = -1;
        if (same1[a] == 0)
            ret = CollectRelics(ord[a], ord[L.back()]);
        if (ret != -1) {
            out[a] = out[L.back()] = ret;
            continue;
        }
        for (int j = a; j < b; ++j) {
            if (same[j] || same1[j]) {
                continue;
            }
            int ret = CollectRelics(ord[c], ord[j]);
            if (ret != -1) {
                out[c] = out[j] = ret;
            }
            else if ((del -= 2) < -1) break;
        }
        if (del < -1) break;
    }
    for (int i = L.back(); i < n; ++i) {
        if (same[i]) continue;
        int ret = CollectRelics(ord[c], ord[i]);
        if (ret != -1) {
            out[c] = ord[c] = ret;
        }
        else if ((del -= 2) < -1) break;
    }
    if (del < -1) return -1;
    return out[c];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 640 KB Correct : C = 199
2 Correct 6 ms 512 KB Correct : C = 198
3 Correct 6 ms 512 KB Correct : C = 177
4 Correct 6 ms 640 KB Correct : C = 199
5 Incorrect 6 ms 640 KB Wrong
6 Correct 6 ms 568 KB Correct : C = 210
7 Correct 6 ms 512 KB Correct : C = 63
8 Correct 6 ms 640 KB Correct : C = 104
9 Incorrect 5 ms 508 KB Wrong
10 Correct 6 ms 512 KB Correct : C = 119
11 Correct 7 ms 640 KB Correct : C = 126
12 Correct 6 ms 512 KB Correct : C = 118
13 Incorrect 6 ms 640 KB Wrong
14 Correct 5 ms 512 KB Correct : C = 4
15 Incorrect 5 ms 512 KB Wrong
16 Correct 6 ms 640 KB Correct : C = 103
17 Incorrect 6 ms 512 KB Wrong
18 Correct 6 ms 384 KB Correct : C = 0
19 Correct 6 ms 640 KB Correct : C = 203
20 Correct 6 ms 640 KB Correct : C = 200
21 Correct 6 ms 512 KB Correct : C = 119
22 Correct 5 ms 512 KB Correct : C = 125
23 Correct 6 ms 640 KB Correct : C = 200
24 Correct 6 ms 640 KB Correct : C = 280
25 Correct 6 ms 640 KB Correct : C = 121
26 Correct 6 ms 640 KB Correct : C = 217
27 Correct 6 ms 512 KB Correct : C = 120