Submission #151188

# Submission time Handle Problem Language Result Execution time Memory
151188 2019-09-02T04:47:14 Z babo Lokahian Relics (FXCUP4_lokahia) C++17
0 / 100
1000 ms 636 KB
#include <bits/stdc++.h>
#define x first
#define y second

using namespace std;

int CollectRelics(int,int);

set<pair<int,int> >st,st2;

int FindBase(int N){
	int i;
	for(i=0;i<N;i++)
	{
		st.insert(make_pair(1,i));
	}
	while(st.size()>=2)
	{
		//printf("%d %d %d %d %d\n",st.begin()->y,next(st.begin())->y,st.begin()->x,next(st.begin())->x,CollectRelics(st.begin()->y,next(st.begin())->y));
		if(st.begin()->x==next(st.begin())->x)
		{
			if(CollectRelics(st.begin()->y,next(st.begin())->y)!=-1)
			{
				st.erase(next(st.begin()));
				st.insert(make_pair(st.begin()->x*2,st.begin()->y));
				st.erase(st.begin());	
			}
			else
			{
				st2.insert(*st.begin());
				st.erase(st.begin());
				st2.insert(*st.begin());
				st.erase(st.begin());
			}
		}
		else
		{
			st2.insert(*st.begin());
			st.erase(st.begin());
		}
	}
	int las=st.begin()->y;
	//printf("las %d sz %d\n",las,sz[las]);
	int ans=st.begin()->x;
	st.erase(st.begin());
	for(set<pair<int,int> >::iterator it=st2.begin();it!=st2.end();it++)
	{
		int temp=CollectRelics(las,it->y);
		if(temp!=-1)
		{
			las=temp;
			ans++;
		}
	}
	if(ans>=N%2?N/2+1:N/2)
		return las;
	return -1;
}
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 628 KB Wrong
2 Correct 3 ms 632 KB Correct : C = 198
3 Incorrect 2 ms 632 KB Wrong
4 Incorrect 3 ms 632 KB Wrong
5 Execution timed out 3004 ms 504 KB Time limit exceeded
6 Correct 2 ms 376 KB Correct : C = 4
7 Correct 2 ms 504 KB Correct : C = 163
8 Incorrect 2 ms 632 KB Wrong
9 Correct 2 ms 632 KB Correct : C = 119
10 Incorrect 3 ms 632 KB Wrong
11 Correct 3 ms 632 KB Correct : C = 199
12 Execution timed out 3052 ms 632 KB Time limit exceeded
13 Correct 2 ms 376 KB Correct : C = 0
14 Incorrect 3 ms 632 KB Wrong
15 Execution timed out 3030 ms 504 KB Time limit exceeded
16 Correct 3 ms 632 KB Correct : C = 271
17 Execution timed out 3042 ms 504 KB Time limit exceeded
18 Correct 2 ms 504 KB Correct : C = 163
19 Execution timed out 3003 ms 632 KB Time limit exceeded
20 Incorrect 2 ms 504 KB Wrong
21 Correct 2 ms 636 KB Correct : C = 264
22 Correct 3 ms 632 KB Correct : C = 272
23 Incorrect 2 ms 504 KB Wrong
24 Correct 2 ms 504 KB Correct : C = 158
25 Correct 2 ms 632 KB Correct : C = 118
26 Execution timed out 3040 ms 504 KB Time limit exceeded
27 Execution timed out 3010 ms 632 KB Time limit exceeded