Submission #1166206

#TimeUsernameProblemLanguageResultExecution timeMemory
1166206crackheadLibrary (JOI18_library)C++20
Compilation error
0 ms0 KiB
#include <cstdio>
#include <vector>
#include "library.h"
using namespace std;

std::vector <int> arr;

bool can(int mid, int node, int N){
	std::vector <int> temp(N, 0);
	for(int i=0; i<=mid; i++){
		temp[arr[i]]=1;
	}
	int without=Query(temp);
	temp[node]=1;
	if(Query(temp)==without+1) return true;
	else return false;
}

void Solve(int N)
{
	vector<int> M(N);
	std::vector <int> qry(N, 1), res;
	set<int> st;
	for(int i=0; i<N; i++) arr.push_back(i);//all is 0 indexed
	
	//find one leaf of the line
	int node;//u gonna find the adj of this node 
	for(int i=0; i<N; i++){
		qry[arr[i]]=0;
		if(Query(qry)==1){
			node=i;
			break;
		}
		qry[arr[i]]=1;
	}
	for(int i=0; i<N; i++){
		//bsta on each one to find adj
		res.push_back(node+1);
		auto it=find(arr.begin(), arr.end(), node);
		arr.erase(it);
		
		int lo=-1, hi=arr.size();
		while(lo+1<hi){
			int mid=(lo+hi)/2;
			if(can(mid, node, N)) lo=mid;
			else hi=mid;
		}
		//hi is adj?
		node=arr[hi];
	}
	

	Answer(res);
}

Compilation message (stderr)

library.cpp: In function 'void Solve(int)':
library.cpp:23:9: error: 'set' was not declared in this scope
   23 |         set<int> st;
      |         ^~~
library.cpp:4:1: note: 'std::set' is defined in header '<set>'; did you forget to '#include <set>'?
    3 | #include "library.h"
  +++ |+#include <set>
    4 | using namespace std;
library.cpp:23:13: error: expected primary-expression before 'int'
   23 |         set<int> st;
      |             ^~~