답안 #379239

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
379239 2021-03-17T14:51:55 Z tqbfjotld 로카히아 유적 (FXCUP4_lokahia) C++17
0 / 100
2 ms 748 KB
#include <bits/stdc++.h>
using namespace std;
#include "lokahia.h"

int X[205];
int retval[205];

int FindBase(int N){
    for (int x = 0; x<N; x++){
        X[x] = x;
    }
    for (int x = 0; x<N-1; x++){
        retval[x+1] = CollectRelics(x,x+1);
        if (retval[x+1]!=-1){
            X[x+1] = X[x];
        }
    }
    int longest = -1;
    int longpos = -1;
    for (int x = 0; x<N; x++){
        if (x-X[x]>longest){
            longest = x-X[x];
            longpos = x;
        }
    }
    int fingroup = X[longpos];
    int cur = N-1;
    int compsize = 0;
    int ans = -1;
    for (int x = fingroup+1; X[x]==fingroup; x++){
        ans = max(ans,retval[x]);
    }
    int queryCount = N-1;
    vector<int> stuff;
    while (cur!=-1){
        if (compsize>N/2) return ans;
        if (queryCount==300) return -1;
        if (cur==fingroup){
            compsize++;
            if (X[cur]==0) cur = -1;
            else cur = X[X[cur]-1]-1;
            continue;
        }
        int ret = CollectRelics(cur,fingroup);
        queryCount++;
        if (ret==-1){
            cur = X[cur]-1;
            continue;
        }
        else{
            for (int x = cur; X[x]==X[cur]&&x>=0; x--){
                if (x!=fingroup)stuff.push_back(x);
            }
            compsize += cur-X[cur]+1;
            ans = max(ans,ret);
            if (X[cur]==0) cur = -1;
            else cur = X[X[cur]-1]-1;
        }

    }
    for (auto x : stuff){
        assert(CollectRelics(x,ans)!=-1);
    }
	return compsize>N/2?ans:-1;
}

# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 620 KB Wrong
2 Incorrect 1 ms 492 KB Wrong
3 Correct 1 ms 620 KB Correct : C = 161
4 Incorrect 1 ms 492 KB Wrong
5 Incorrect 1 ms 620 KB Wrong
6 Correct 1 ms 620 KB Correct : C = 274
7 Correct 1 ms 620 KB Correct : C = 238
8 Correct 1 ms 620 KB Correct : C = 236
9 Correct 1 ms 620 KB Correct : C = 300
10 Incorrect 2 ms 620 KB Wrong
11 Incorrect 1 ms 620 KB Wrong
12 Correct 1 ms 620 KB Correct : C = 278
13 Incorrect 2 ms 748 KB Wrong
14 Correct 1 ms 492 KB Correct : C = 0
15 Correct 2 ms 620 KB Correct : C = 300
16 Incorrect 2 ms 620 KB Wrong
17 Incorrect 1 ms 640 KB Wrong
18 Correct 1 ms 620 KB Correct : C = 300
19 Incorrect 2 ms 620 KB Wrong
20 Incorrect 1 ms 620 KB Wrong
21 Incorrect 1 ms 620 KB Wrong
22 Correct 1 ms 620 KB Correct : C = 300
23 Incorrect 2 ms 620 KB Wrong
24 Incorrect 2 ms 620 KB Wrong
25 Incorrect 1 ms 640 KB Wrong
26 Incorrect 1 ms 620 KB Wrong
27 Incorrect 1 ms 620 KB Wrong