Submission #151197

# Submission time Handle Problem Language Result Execution time Memory
151197 2019-09-02T06:42:57 Z babo Lokahian Relics (FXCUP4_lokahia) C++17
0 / 100
4 ms 1272 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(st.begin()->y==next(st.begin())->y) printf("%d\n",1/0);
			int temp=CollectRelics(st.begin()->y,next(st.begin())->y);
			if(temp!=-1)
			{
				st.erase(next(st.begin()));
				st.insert(make_pair(st.begin()->x*2,temp));
				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());
		}
	}
	if(st.empty()) return -1;
	int las=st.begin()->y;
	int ans=st.begin()->x;
	st.erase(st.begin());
	for(set<pair<int,int> >::iterator it=st2.begin();it!=st2.end();it++)
	{
		if(las,it->y) printf("%d\n",1/0);
		int temp=CollectRelics(las,it->y);
		if(temp!=-1)
		{
			las=temp;
			ans+=it->x;
		}
	}
	if(ans>N/2)
		return las;
	return -1;
}

Compilation message

lokahia.cpp: In function 'int FindBase(int)':
lokahia.cpp:22:58: warning: division by zero [-Wdiv-by-zero]
    if(st.begin()->y==next(st.begin())->y) printf("%d\n",1/0);
                                                         ~^~
lokahia.cpp:3:11: warning: left operand of comma operator has no effect [-Wunused-value]
 #define y second
           ^
lokahia.cpp:50:14: note: in expansion of macro 'y'
   if(las,it->y) printf("%d\n",1/0);
              ^
lokahia.cpp:50:32: warning: division by zero [-Wdiv-by-zero]
   if(las,it->y) printf("%d\n",1/0);
                               ~^~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 632 KB Correct : C = 103
2 Incorrect 2 ms 504 KB Wrong
3 Runtime error 4 ms 1144 KB Execution killed with signal 4 (could be triggered by violating memory limits)
4 Runtime error 3 ms 1016 KB Execution killed with signal 4 (could be triggered by violating memory limits)
5 Runtime error 4 ms 1016 KB Execution killed with signal 4 (could be triggered by violating memory limits)
6 Incorrect 3 ms 632 KB Wrong
7 Runtime error 4 ms 888 KB Execution killed with signal 4 (could be triggered by violating memory limits)
8 Correct 3 ms 632 KB Correct : C = 100
9 Incorrect 3 ms 504 KB Wrong
10 Incorrect 3 ms 632 KB Wrong
11 Incorrect 3 ms 632 KB Wrong
12 Correct 3 ms 632 KB Correct : C = 101
13 Correct 3 ms 632 KB Correct : C = 101
14 Runtime error 4 ms 1016 KB Execution killed with signal 4 (could be triggered by violating memory limits)
15 Runtime error 4 ms 1020 KB Execution killed with signal 4 (could be triggered by violating memory limits)
16 Incorrect 3 ms 632 KB Wrong
17 Runtime error 3 ms 760 KB Execution killed with signal 4 (could be triggered by violating memory limits)
18 Correct 3 ms 632 KB Correct : C = 101
19 Runtime error 4 ms 1016 KB Execution killed with signal 4 (could be triggered by violating memory limits)
20 Incorrect 3 ms 632 KB Wrong
21 Runtime error 4 ms 1144 KB Execution killed with signal 4 (could be triggered by violating memory limits)
22 Incorrect 3 ms 632 KB Wrong
23 Runtime error 4 ms 888 KB Execution killed with signal 4 (could be triggered by violating memory limits)
24 Runtime error 3 ms 1016 KB Execution killed with signal 4 (could be triggered by violating memory limits)
25 Correct 2 ms 376 KB Correct : C = 0
26 Correct 2 ms 632 KB Correct : C = 60
27 Runtime error 4 ms 1272 KB Execution killed with signal 4 (could be triggered by violating memory limits)