Submission #148197

# Submission time Handle Problem Language Result Execution time Memory
148197 2019-08-31T17:12:31 Z 조팍시\n123(#3740, tlwpdus, ainta, cki86201) Lokahian Relics (FXCUP4_lokahia) C++17
0 / 100
7 ms 768 KB
#include <bits/stdc++.h>
#include "lokahia.h"
using namespace std;

#define Fi first
#define Se second
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define szz(x) (int)(x).size()
#define rep(i, n) for(int i=0;i<(n);i++)
typedef tuple<int, int, int> t3;

int arr[210];
int myc(int x, int y) {
	if(x == y) return x;
	int v = CollectRelics(x - 1, y - 1);
	if(v == -1) return -1;
	return v + 1;
}
int rev[210], rev2[210];
int FindBase(int N) {
	vector <int> V, V2;
	for(int i=1, p=1, cnt=0, st=1;i<=N;i++) {
		if(i == p) ++cnt, arr[i] = 2;
		else {
			int v = myc(p, i);
			if(v == -1) --cnt;
			else {
				++cnt;
				arr[i] = 1;
				p = v;
			}
		}
		if(cnt == 0 || i == N) {
			V.pb(p);
			V2.pb(st);
			rev[st] = p;
			p = i + 1;
			st = i + 1;
		}
	}
	vector <int> List;
	int res = V.back(), pp = V2.back();
	for(int i=pp;i<=N;i++) if(arr[i] == 2 || arr[i] == 1) List.pb(i);
	for(int i=1;i<pp;i++) {
		if(arr[i] == 2) {
			int ri = rev[i];
			int v = myc(ri, res);
			if(v != -1) {
				List.pb(i);
				res = v;
				for(int j=i+1;arr[j]!=2;j++) if(arr[j]) List.pb(j);
			}
			else {
				for(int j=i+1;arr[j]!=2;j++) {
					if(arr[j]) continue;
					int v = myc(j, res);
					if(v != -1) List.pb(j), res = v;
				}
			}
		}
	}
	if(szz(List) >= N / 2 + 1) {
		return res - 1;
	}

	return -1;
}
# Verdict Execution time Memory Grader output
1 Correct 7 ms 640 KB Correct : C = 198
2 Incorrect 7 ms 616 KB Wrong
3 Correct 6 ms 640 KB Correct : C = 297
4 Correct 6 ms 600 KB Correct : C = 177
5 Correct 6 ms 512 KB Correct : C = 4
6 Correct 7 ms 640 KB Correct : C = 198
7 Correct 6 ms 640 KB Correct : C = 203
8 Incorrect 6 ms 512 KB Wrong
9 Correct 6 ms 604 KB Correct : C = 298
10 Correct 7 ms 640 KB Correct : C = 276
11 Correct 6 ms 512 KB Correct : C = 176
12 Correct 5 ms 688 KB Correct : C = 117
13 Correct 6 ms 640 KB Correct : C = 178
14 Correct 6 ms 556 KB Correct : C = 120
15 Correct 6 ms 512 KB Correct : C = 0
16 Correct 6 ms 604 KB Correct : C = 202
17 Correct 6 ms 640 KB Correct : C = 199
18 Correct 7 ms 640 KB Correct : C = 262
19 Incorrect 7 ms 640 KB Wrong
20 Correct 6 ms 640 KB Correct : C = 205
21 Correct 7 ms 768 KB Correct : C = 118
22 Correct 6 ms 640 KB Correct : C = 197
23 Incorrect 7 ms 640 KB Wrong
24 Correct 6 ms 596 KB Correct : C = 117
25 Incorrect 6 ms 640 KB Wrong
26 Correct 7 ms 604 KB Correct : C = 119
27 Correct 6 ms 640 KB Correct : C = 197