Submission #128311

# Submission time Handle Problem Language Result Execution time Memory
128311 2019-07-10T16:35:30 Z mohammedehab2002 Minerals (JOI19_minerals) C++14
Compilation error
0 ms 0 KB
#include "minerals.h"
#include <vector>
#include "grader.cpp"
using namespace std;
int cur=0;
pair<int,int> dp[43005][2];
vector<int> v1,v2;
bool query(int x)
{
	int tmp=Query(x);
	if (cur==tmp)
	return 1;
	cur=tmp;
	return 0;
}
void solve(vector<int> a,vector<int> b,bool added)
{
	if (a.empty())
	return;
	if (a.size()==1)
	{
		Answer(a[0],b[0]);
		return;
	}
	int mid=dp[a.size()][added].second;
	if (a.size()>6000)
	{
		mid=(15*a.size()+4)/24;
		if (!added)
		mid=(9*a.size()+4)/24;
	}
	vector<int> aa[2],bb[2];
	for (int i=0;i<a.size();i++)
	{
		if (i<mid)
		{
			aa[0].push_back(a[i]);
			if (!added)
			query(a[i]);
		}
		else
		{
			aa[1].push_back(a[i]);
			if (added)
			query(a[i]);
		}
	}
	for (int i=0;i<b.size()-1;i++)
	{
		if (query(b[i]))
		bb[0].push_back(b[i]);
		else
		bb[1].push_back(b[i]);
	}
	if (aa[0].size()==bb[0].size())
	bb[1].push_back(b.back());
	else
	bb[0].push_back(b.back());
	solve(aa[0],bb[0],1);
	solve(aa[1],bb[1],0);
}
void Solve(int n)
{
	for (int i=1;i<=2*n;i++)
	{
		if (query(i))
		v2.push_back(i);
		else
		v1.push_back(i);	
	}
	for (int i=2;i<=6000;i++)
	{
		dp[i][0]={1e9,-1};
		dp[i][1]={1e9,-1};
		for (int j=1;j<=i-1;j++)
		{
			dp[i][0]=min(dp[i][0],{dp[j][1].first+dp[i-j][0].first+j+i-1,j});
			dp[i][1]=min(dp[i][1],{dp[j][1].first+dp[i-j][0].first+i-j+i-1,j});
		}
	}
	solve(v1,v2,1);
}

Compilation message

minerals.cpp: In function 'void solve(std::vector<int>, std::vector<int>, bool)':
minerals.cpp:33:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i=0;i<a.size();i++)
               ~^~~~~~~~~
minerals.cpp:48:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i=0;i<b.size()-1;i++)
               ~^~~~~~~~~~~
/tmp/ccDeTA7D.o: In function `Query(int)':
grader.cpp:(.text+0x20): multiple definition of `Query(int)'
/tmp/ccpqm0xL.o:minerals.cpp:(.text+0x20): first defined here
/tmp/ccDeTA7D.o: In function `Answer(int, int)':
grader.cpp:(.text+0xf0): multiple definition of `Answer(int, int)'
/tmp/ccpqm0xL.o:minerals.cpp:(.text+0xf0): first defined here
/tmp/ccDeTA7D.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccpqm0xL.o:minerals.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status