Submission #820284

# Submission time Handle Problem Language Result Execution time Memory
820284 2023-08-11T03:26:27 Z Faisal_Saqib Library (JOI18_library) C++17
0 / 100
1 ms 208 KB
#include <bits/stdc++.h>
#include "library.h"
// #include "grader.cpp"
using namespace std;
int par[3000];
int get(int x)
{
	if(x==par[x])
	{
		return x;
	}
	return par[x]=get(par[x]);
}
void join(int a,int b)
{
	a=get(a);
	b=get(b);
	par[a]=b;
}
bool check(vector<int> a,int b)
{
	a.push_back(b);
	int x=Query(a);
	if(x==a.size())
	{
		return 0;	
	}
	else
	{
		return 1;
	}
}
void find(vector<int> a,int x)
{
	if(a.size()==1)
	{
		join(a[0],x);
		return;
	}
	vector<int> fh,sh;
	for(int i=0;i<a.size();i++)
	{
		if(i<(a.size()/2))
		{
			fh.push_back(a[i]);
		}
		else
		{
			sh.push_back(a[i]);
		}
	}
	if(check(fh,x))
	{
		find(fh,x);
	}
	else
	{
		find(sh,x);
	}
}
void Solve(int n)
{
	vector<int> h;
	h.push_back(1);
	for(int i=2;i<=n;i++)
	{
		h.push_back(i);
		int x=Query(h);
		if(x==h.size())
		{
			h.pop_back();
			find(h,i);
		}
	}
	vector<int> ans(n);
	map<int,vector<int>> ma;
	for(int i=1;i<=n;i++)
	{
		ma[get(i)].push_back(i);
	}
	int cur=0;
	for(auto i:ma)
	{
		for(auto j:i.second)
		{
			ans[cur]=j;
			cur++;
		}
	}
	for(auto i:ans)
	{
		cout<<i<<' ';
	}
	cout<<endl;
	Answer(ans);
}

Compilation message

library.cpp: In function 'bool check(std::vector<int>, int)':
library.cpp:24:6: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |  if(x==a.size())
      |     ~^~~~~~~~~~
library.cpp: In function 'void find(std::vector<int>, int)':
library.cpp:41:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |  for(int i=0;i<a.size();i++)
      |              ~^~~~~~~~~
library.cpp:43:7: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |   if(i<(a.size()/2))
      |      ~^~~~~~~~~~~~~
library.cpp: In function 'void Solve(int)':
library.cpp:69:7: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   69 |   if(x==h.size())
      |      ~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 208 KB Wrong Answer [1]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 208 KB Wrong Answer [1]
2 Halted 0 ms 0 KB -