답안 #15647

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
15647 2015-07-14T02:28:56 Z gs14004 최후의 만찬 (IOI12_supper) C++14
컴파일 오류
0 ms 0 KB
#include "advisor.h"
#include <vector>
#include <algorithm>
#include <set>
using namespace std;
typedef pair<int,int> pi;

set<pi> s;
vector<pi> nexts;
int query[100005];
int is_in[100005];

int getnxt(int val, int time){
	auto t = upper_bound(nexts.begin(), nexts.end(), pi(val, time));
	if(t->first != val) return 1e9;
	return t->second;
}

bool PopPrevRequest[100005];
bool PopK[25005];

void ComputeAdvice(int *C, int N, int K, int M) {
	for(int i=0; i<N; i++){
		nexts.push_back(pi(C[i], i));
	}
	sort(nexts.begin(), nexts.end());
	for(int i=0; i<K; i++){
		s.insert(pi(getnxt(i, -1), i));
		is_in[i] = 1;
	}
	for(int i=0; i<N; i++){
		query[i] = N;
		if(is_in[C[i]]){
			if(s.find(pi(i, C[i])) != s.end()) s.erase(pi(i, C[i]));
			s.insert(pi(getnxt(C[i], i), C[i]));	
		}
		else{
			auto t = --s.end();
			query[i] = t->second;
			is_in[t->second] = 0;
			s.erase(t);
			s.insert(pi(getnxt(C[i], i), C[i]));
			is_in[C[i]] = 1;
		}
	}
	for(int i=0; i<N; i++){
		if(query[i] != N){
			auto t = lower_bound(nexts.begin(), nexts.end(), pi(query[i], i));
			if(t == nexts.begin() || (t-1)->first != query[i]){
				PopK[query[i]] = 1;
			}
			else{
				t--;
				PopPrevRequest[t->second] = 1;
			}
			// investigate last use of pop query
		}
	}
	for(int i=0; i<N; i++){
		WriteAdvice(PopPrevRequest[i]);
	}
	for(int i=0; i<K; i++){
		WriteAdvice(PopK[i]);
	}
}
#include "assistant.h"
#include <set>
#include <vector>
using namespace std;
vector<int> pops;
set<int> scaffold;

void Assist(unsigned char *A, int N, int K, int R) {
	int prevReq = -1;
	for(int i=0; i<K; i++){
		scaffold.insert(i);
		if(A[i+N]) pops.push_back(i);
	}
	for(int i=0; i<N; i++){
		int curReq = GetRequest();
		if(scaffold.find(curReq) == scaffold.end()){
			PutBack(pops.back());
			scaffold.erase(pops.back());
			pops.pop_back();
			scaffold.insert(curReq);
		}
		if(A[i]){
			pops.insert(curReq);
		}
	}
}

Compilation message

assistant.cpp: In function 'void Assist(unsigned char*, int, int, int)':
assistant.cpp:23:22: error: no matching function for call to 'std::vector<int>::insert(int&)'
    pops.insert(curReq);
                      ^
In file included from /usr/include/c++/7/vector:69:0,
                 from assistant.cpp:3:
/usr/include/c++/7/bits/vector.tcc:114: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 = __gnu_cxx::__normal_iterator<int*, std::vector<int> >; typename std::_Vector_base<_Tp, _Alloc>::pointer = int*; std::vector<_Tp, _Alloc>::const_iterator = __gnu_cxx::__normal_iterator<const int*, std::vector<int> >; typename __gnu_cxx::__alloc_traits<typename std::_Vector_base<_Tp, _Alloc>::_Tp_alloc_type>::const_pointer = const int*; std::vector<_Tp, _Alloc>::value_type = int]
     vector<_Tp, _Alloc>::
     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/7/bits/vector.tcc:114:5: note:   candidate expects 2 arguments, 1 provided
In file included from /usr/include/c++/7/vector:64:0,
                 from assistant.cpp:3:
/usr/include/c++/7/bits/stl_vector.h:1042: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 = __gnu_cxx::__normal_iterator<int*, std::vector<int> >; typename std::_Vector_base<_Tp, _Alloc>::pointer = int*; std::vector<_Tp, _Alloc>::const_iterator = __gnu_cxx::__normal_iterator<const int*, std::vector<int> >; typename __gnu_cxx::__alloc_traits<typename std::_Vector_base<_Tp, _Alloc>::_Tp_alloc_type>::const_pointer = const int*; std::vector<_Tp, _Alloc>::value_type = int]
       insert(const_iterator __position, value_type&& __x)
       ^~~~~~
/usr/include/c++/7/bits/stl_vector.h:1042:7: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/7/bits/stl_vector.h:1059: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 = __gnu_cxx::__normal_iterator<int*, std::vector<int> >; typename std::_Vector_base<_Tp, _Alloc>::pointer = int*; std::vector<_Tp, _Alloc>::const_iterator = __gnu_cxx::__normal_iterator<const int*, std::vector<int> >; typename __gnu_cxx::__alloc_traits<typename std::_Vector_base<_Tp, _Alloc>::_Tp_alloc_type>::const_pointer = const int*]
       insert(const_iterator __position, initializer_list<value_type> __l)
       ^~~~~~
/usr/include/c++/7/bits/stl_vector.h:1059:7: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/7/bits/stl_vector.h:1084: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 = __gnu_cxx::__normal_iterator<int*, std::vector<int> >; typename std::_Vector_base<_Tp, _Alloc>::pointer = int*; std::vector<_Tp, _Alloc>::const_iterator = __gnu_cxx::__normal_iterator<const int*, std::vector<int> >; typename __gnu_cxx::__alloc_traits<typename std::_Vector_base<_Tp, _Alloc>::_Tp_alloc_type>::const_pointer = const int*; std::vector<_Tp, _Alloc>::size_type = long unsigned int; std::vector<_Tp, _Alloc>::value_type = int]
       insert(const_iterator __position, size_type __n, const value_type& __x)
       ^~~~~~
/usr/include/c++/7/bits/stl_vector.h:1084:7: note:   candidate expects 3 arguments, 1 provided
/usr/include/c++/7/bits/stl_vector.h:1128: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>]
  insert(const_iterator __position, _InputIterator __first,
  ^~~~~~
/usr/include/c++/7/bits/stl_vector.h:1128:2: note:   template argument deduction/substitution failed:
assistant.cpp:23:22: note:   candidate expects 3 arguments, 1 provided
    pops.insert(curReq);
                      ^
assistant.cpp:9:6: warning: unused variable 'prevReq' [-Wunused-variable]
  int prevReq = -1;
      ^~~~~~~