답안 #229311

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
229311 2020-05-04T07:19:57 Z 534351 로카히아 유적 (FXCUP4_lokahia) C++17
77 / 100
7 ms 640 KB
#include "lokahia.h"
#include <bits/stdc++.h>

using namespace std;

template<class T, class U>
void ckmin(T &a, U b)
{
    if (a > b) a = b;
}

template<class T, class U>
void ckmax(T &a, U b)
{
    if (a < b) a = b;
}

#define MP make_pair
#define PB push_back
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
#define SZ(x) ((int) (x).size())
#define ALL(x) (x).begin(), (x).end()
#define FOR(i, a, b) for (auto i = (a); i < (b); i++)
#define FORD(i, a, b) for (auto i = (a) - 1; i >= (b); i--)

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef vector<pll> vpl;

map<int, int> mp[213];

int ask(int i, int j)
{
    if (mp[i].count(j))
    {
        return mp[i][j];
    }
    int res = CollectRelics(i, j);
    mp[i][j] = res;
    mp[j][i] = res;
    return res;
}
int FindBase(int N)
{
    if (N == 1)
    {
        return 0;
    }
    if (N == 2)
    {
        return ask(0, 1);
    }
    int maj = -1, cnt = 0;
    FOR(i, 0, N - 1)
    {
        if (cnt == 0)
        {
            maj = i;
            cnt++;
        }
        else
        {
            int w = ask(maj, i);
            if (w == -1)
            {
                cnt--;
            }
            else
            {
                maj = i;
                cnt++;
            }
        }
    }
    if (cnt == 0) maj = N - 1;
    cnt = 1;
    int net = 1;
    int res = maj; int mx = -1;
    FOR(i, 0, N)
    {
        if (i == maj) continue;
        int w = ask(maj, i);
        if (w != -1)
        {
            ckmax(mx, w);
            cnt++;
            if (w == res)
            {
                net++;
            }
            else
            {
                net--;
                if (net == 0)
                {
                    res = w;
                    net = 1;
                }
            }
        }
    }
    if (cnt <= N / 2) return -1;
    assert(mx == res);
    return res;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 512 KB Correct : C = 0
2 Correct 5 ms 640 KB Correct : C = 227
3 Partially correct 5 ms 640 KB Partially correct : C = 380
4 Partially correct 5 ms 640 KB Partially correct : C = 383
5 Correct 5 ms 640 KB Correct : C = 228
6 Partially correct 7 ms 640 KB Partially correct : C = 386
7 Partially correct 5 ms 640 KB Partially correct : C = 309
8 Correct 6 ms 640 KB Correct : C = 233
9 Partially correct 5 ms 640 KB Partially correct : C = 382
10 Partially correct 5 ms 640 KB Partially correct : C = 394
11 Correct 5 ms 640 KB Correct : C = 297
12 Correct 5 ms 640 KB Correct : C = 222
13 Correct 5 ms 640 KB Correct : C = 298
14 Partially correct 5 ms 640 KB Partially correct : C = 317
15 Correct 5 ms 640 KB Correct : C = 236
16 Partially correct 5 ms 640 KB Partially correct : C = 384
17 Partially correct 5 ms 640 KB Partially correct : C = 396
18 Correct 5 ms 640 KB Correct : C = 178
19 Partially correct 7 ms 640 KB Partially correct : C = 393
20 Correct 5 ms 640 KB Correct : C = 234
21 Partially correct 6 ms 640 KB Partially correct : C = 387
22 Correct 5 ms 512 KB Correct : C = 6
23 Correct 5 ms 640 KB Correct : C = 233
24 Partially correct 6 ms 640 KB Partially correct : C = 379
25 Correct 5 ms 640 KB Correct : C = 223
26 Partially correct 5 ms 640 KB Partially correct : C = 394
27 Correct 5 ms 640 KB Correct : C = 177