답안 #994884

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
994884 2024-06-08T08:10:02 Z lollipop 도서관 (JOI18_library) C++17
컴파일 오류
0 ms 0 KB
#include "library.h" 

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
//#define int long long
#define pb push_back
#define s second
#define f first
#define pf push_front
#define inf 100000000000000000
#define bitebi __builtin_popcountll
#define FOR( i , n ) for( int i = 0 ; i < n ; i ++ )
#define YES cout <<"YES\n"
#define NO cout << "NO\n"
#define debug cout << "Here Fine" << endl ;
#define pr pair < int , int >
#define fbo find_by_order // returns iterator
#define ook order_of_key // returns strictly less numbers than key
using namespace std ;
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
using namespace __gnu_pbds;
using namespace __gnu_cxx;
template<class T> using ordered_set =tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update> ;
const double Pi=acos(-1.0);
const double EPS=1E-8;
const int mod =  1000000007 ;
const int mod1 = 998244353 ;
const int N = 2e5 + 10 ;
mt19937 R(time(0));
map < int , int > ma , ma1 ;

//namespace {
//struct Judge
//{
//	int N;
//	int A[1002];
//	int pos[1002];
//	bool f[1002];
//	int query_c;
//	bool answered;
//	void init()
//	{
//		query_c=0;
//		int ret=scanf("%d",&N); ret++;
//		answered=false;
//		for(int i=0;i<N;i++)ret=scanf("%d",&A[i]),pos[A[i]]=i;
//	}
//	int query(const vector<int>& M)
//	{
//		if(query_c==20000)
//		{
//			puts("Wrong Answer [3]");
//			exit(0);
//		}
//		if(int(M.size())!=N)
//		{
//			puts("Wrong Answer [1]");
//			exit(0);
//		}
//		bool all_zero=true;
//		for(int i=0;i<N;i++)
//		{
//			if(M[i]!=0&&M[i]!=1)
//			{
//				puts("Wrong Answer [2]");
//				exit(0);
//			}
//			if(M[i]==1)all_zero=false;
//		}
//		if(all_zero)
//		{
//			puts("Wrong Answer [2]");
//			exit(0);
//		}
//		memset(f,0,sizeof(f));
//		for(int i=0;i<N;i++)if(M[i])f[pos[i+1]]=true;
//		bool las=false;
//		int r=0;
//		for(int i=0;i<N;i++)
//		{
//			if(las==false&&f[i]==true)r++;
//			las=f[i];
//		}
//		query_c++;
//		return r;
//	}
//	void answer(const vector<int>& res)
//	{
//		bool f1=true,f2=true;
//		if(int(res.size())!=N)
//		{
//			puts("Wrong Answer [4]");
//			exit(0);
//		}
//		if(answered)
//		{
//			puts("Wrong Answer [7]");
//			exit(0);
//		}
//		answered=true;
//		memset(f,0,sizeof(f));
//		for(int i=0;i<N;i++)
//		{
//			if(res[i]<=0||res[i]>N)
//			{
//				puts("Wrong Answer [5]");
//				exit(0);
//			}
//			if(f[res[i]])
//			{
//				puts("Wrong Answer [6]");
//				exit(0);
//			}
//			f[res[i]]=true;
//		}
//		for(int i=0;i<N;i++)
//		{
//			f1&=A[i]==res[i];
//			f2&=A[i]==res[N-i-1];
//		}
//		if(!f1&&!f2)
//		{
//			puts("Wrong Answer [8]");
//			exit(0);
//		}
//	}
//	void end()
//	{
//		if(!answered)puts("Wrong Answer [7]");
//		else printf("Accepted : %d\n",query_c);
//	}
//}judge;
//}
//
//int Query(const vector<int>& M)
//{
//	return judge.query(M);
//}
//void Answer(const vector<int>& res)
//{
//	judge.answer(res);
//}

// int Query( vector )
// void Answer ( vector ) 

vector < int > ans , lf , cur ;
void Solve( int n ){

    
    for( int i = 2 ; i <= n ; i ++ ) lf.pb( i ) ;
    ans.pb( 1 ) ; 
    FOR( i , n ) cur.pb( 0 ) ; 
    while( true ){
    	int ss = ans.size() ;
    	if( ss == n ) break ; 
    	int l = 0 , r = lf.size() - 1 ;
    	while( l < r ){
    		int mid = ( l + r ) / 2 ; 
    		FOR( i , n ) cur[ i ] = 0 ; 
    		for( int j = 0 ; j <= mid ; j ++ ) cur[ lf[ j ] - 1 ] = 1 ; 
    		int nmb ; 
    		 nmb = Query( cur ) ; 
    		 //cout << nmb << endl ;
    		for( auto x : ans ) cur[ x - 1 ] = 1 ;  
    		int nmb1 ;
    		 nmb1 = Query( cur ) ; 
    		 //cout << nmb1 << endl ;
    		if( nmb1 == nmb ){
    			r = mid ; continue ; 
			}
			else{
				l = mid + 1 ; continue ;
			}	
		}
		// gipovia mezobeli -- l -- shia
		int node = lf[ l ] ; 
		lf.erase( lf.begin() + l ) ;
	    int nmb ;
	    FOR( i , n ) cur[ i ] = 0 ;
		cur[ node - 1 ] = 1 ;
		cur[ ans[ 0 ] - 1 ] = 1 ;   
	     nmb = Query( cur ) ; 
	    if( nmb == 2 ){
	    	ans.pb( node ) ; 
		}
		else ans.insert( 0 , node ) ;
    	
	}
	 Answer( ans ) ; 

}

//int main()
//{
//	judge.init();
//	Solve(judge.N);
//	judge.end();
//}




Compilation message

library.cpp: In function 'void Solve(int)':
library.cpp:190:29: error: no matching function for call to 'std::vector<int>::insert(int, int&)'
  190 |   else ans.insert( 0 , node ) ;
      |                             ^
In file included from /usr/include/c++/10/vector:72,
                 from library.h:1,
                 from library.cpp:1:
/usr/include/c++/10/bits/vector.tcc:130:5: note: candidate: 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::insert(std::vector<_Tp, _Alloc>::const_iterator, const value_type&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::iterator = std::vector<int>::iterator; std::vector<_Tp, _Alloc>::const_iterator = std::vector<int>::const_iterator; std::vector<_Tp, _Alloc>::value_type = int]'
  130 |     vector<_Tp, _Alloc>::
      |     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/bits/vector.tcc:132:27: note:   no known conversion for argument 1 from 'int' to 'std::vector<int>::const_iterator'
  132 |     insert(const_iterator __position, const value_type& __x)
      |            ~~~~~~~~~~~~~~~^~~~~~~~~~
In file included from /usr/include/c++/10/vector:67,
                 from library.h:1,
                 from library.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:1293:7: note: candidate: 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::insert(std::vector<_Tp, _Alloc>::const_iterator, std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::iterator = std::vector<int>::iterator; std::vector<_Tp, _Alloc>::const_iterator = std::vector<int>::const_iterator; std::vector<_Tp, _Alloc>::value_type = int]'
 1293 |       insert(const_iterator __position, value_type&& __x)
      |       ^~~~~~
/usr/include/c++/10/bits/stl_vector.h:1293:29: note:   no known conversion for argument 1 from 'int' to 'std::vector<int>::const_iterator'
 1293 |       insert(const_iterator __position, value_type&& __x)
      |              ~~~~~~~~~~~~~~~^~~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1310:7: note: candidate: 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::insert(std::vector<_Tp, _Alloc>::const_iterator, std::initializer_list<_Tp>) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::iterator = std::vector<int>::iterator; std::vector<_Tp, _Alloc>::const_iterator = std::vector<int>::const_iterator]'
 1310 |       insert(const_iterator __position, initializer_list<value_type> __l)
      |       ^~~~~~
/usr/include/c++/10/bits/stl_vector.h:1310:29: note:   no known conversion for argument 1 from 'int' to 'std::vector<int>::const_iterator'
 1310 |       insert(const_iterator __position, initializer_list<value_type> __l)
      |              ~~~~~~~~~~~~~~~^~~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1335:7: note: candidate: 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::insert(std::vector<_Tp, _Alloc>::const_iterator, std::vector<_Tp, _Alloc>::size_type, const value_type&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::iterator = std::vector<int>::iterator; std::vector<_Tp, _Alloc>::const_iterator = std::vector<int>::const_iterator; std::vector<_Tp, _Alloc>::size_type = long unsigned int; std::vector<_Tp, _Alloc>::value_type = int]'
 1335 |       insert(const_iterator __position, size_type __n, const value_type& __x)
      |       ^~~~~~
/usr/include/c++/10/bits/stl_vector.h:1335:7: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/10/bits/stl_vector.h:1379:2: note: candidate: 'template<class _InputIterator, class> std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::insert(std::vector<_Tp, _Alloc>::const_iterator, _InputIterator, _InputIterator) [with _InputIterator = _InputIterator; <template-parameter-2-2> = <template-parameter-1-2>; _Tp = int; _Alloc = std::allocator<int>]'
 1379 |  insert(const_iterator __position, _InputIterator __first,
      |  ^~~~~~
/usr/include/c++/10/bits/stl_vector.h:1379:2: note:   template argument deduction/substitution failed:
library.cpp:190:29: note:   candidate expects 3 arguments, 2 provided
  190 |   else ans.insert( 0 , node ) ;
      |                             ^