답안 #152801

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
152801 2019-09-09T15:08:26 Z zscoder 로카히아 유적 (FXCUP4_lokahia) C++17
0 / 100
3 ms 636 KB
#include "lokahia.h"
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef unsigned long long ull;
typedef long double ld; 
typedef tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int used[222];
int rtnumber[222];

map<ii,int> ma;

int ask(int u, int v)
{
	if(ma.find({u,v})!=ma.end()) return ma[{u,v}];
	return (ma[{u,v}]=ma[{v,u}]=CollectRelics(u,v));
}

int FindBase(int N)
{
	int n=N;
	if(n==1) return 0;
	if(n==2)
	{
		return ask(0,1);
	}
	memset(used,0,sizeof(used));
	set<int> S;
	int rt=-1;
	for(int i=0;i<n;i++)
	{
		if(used[i]) continue;
		if(rt==-1)
		{
			S.insert(i); used[i]=1; rt=i; continue;
		}
		int newrt = ask(rt,i);
		if(newrt==-1)
		{
			auto it = (prev(S.end()));
			if(S.size()==1)
			{
				used[rt]=used[i]=1;
				S.clear(); rt=-1; continue; 
			}
			while((*it)==rt)
			{
				it--;
			}
			S.erase(it);
			used[i]=1;
			continue;
		}
		S.insert(i); 
		S.insert(newrt);
		if(newrt!=i&&newrt!=rt)
		{
			if(used[newrt])
			{
				S.erase(i);
			}
		}
		rt=newrt;
	}
	if(S.empty())
	{
		return -1;
	}
	int u = (*S.begin());
	int mx=-1;
	int cnt=1;
	for(int i=0;i<n;i++)
	{
		if(i!=u)
		{
			rtnumber[i]=ask(i,u);
			mx=max(mx,rtnumber[i]);
		}
	}
	if(mx<0) return -1;
	for(int i=0;i<n;i++)
	{
		if(i==mx) continue;
		cnt+=(ask(i,mx)!=-1);
	}
	if(cnt*2>n) return mx;
	else return -1;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 504 KB Correct : C = 131
2 Incorrect 3 ms 504 KB Wrong
3 Incorrect 3 ms 504 KB Wrong
4 Incorrect 3 ms 632 KB Wrong
5 Correct 2 ms 636 KB Correct : C = 60
6 Incorrect 3 ms 632 KB Wrong
7 Incorrect 2 ms 504 KB Wrong
8 Incorrect 3 ms 632 KB Wrong
9 Correct 3 ms 632 KB Correct : C = 111
10 Correct 3 ms 632 KB Correct : C = 211
11 Correct 2 ms 504 KB Correct : C = 177
12 Correct 2 ms 376 KB Correct : C = 0
13 Incorrect 3 ms 632 KB Wrong
14 Correct 2 ms 504 KB Correct : C = 7
15 Correct 2 ms 632 KB Correct : C = 297
16 Incorrect 2 ms 504 KB Wrong
17 Correct 3 ms 632 KB Correct : C = 212
18 Correct 2 ms 632 KB Correct : C = 100
19 Incorrect 2 ms 504 KB Wrong
20 Incorrect 3 ms 632 KB Wrong
21 Correct 3 ms 632 KB Correct : C = 216
22 Incorrect 3 ms 632 KB Wrong
23 Incorrect 3 ms 552 KB Wrong
24 Incorrect 3 ms 632 KB Wrong
25 Incorrect 2 ms 504 KB Wrong
26 Incorrect 2 ms 504 KB Wrong
27 Partially correct 3 ms 632 KB Partially correct : C = 498