답안 #770138

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
770138 2023-06-30T19:42:08 Z APROHACK 고대 책들 (IOI17_books) C++14
컴파일 오류
0 ms 0 KB
#include "books.h"
#include <bits/stdc++.h>
#define ll long long 
#define ff first
#define ss second
#define pb push_back
using namespace std;
int n;
int startTo[1000000];

int searchR(int pos){
	for(int i = pos ; i < n ; i ++){
		if(startTo[i] != -1)return i;
	}
	return -1;
}
ll searchL(ll pos){
	for(int i = 0 ; i < n; i ++){
		if(startTo[i] != -1)return i;
	}
	return -1;
}
ll pos = 0, temp;
ll ans = 0;
void ir(ll siguiente){
	ans += abs(siguiente-pos);
	pos = siguiente;
}

long long minimum_walk(std::vector<> p, int s) {
	n = p.size();int
	for(int i = 0 ; i < n ; i ++){
		startTo[i] = -1;
		if(p[i] > i){
			startTo[i] = p[i];
		}
	}
	
	while(true){
		ll nextL = searchL(pos);
		if(nextL != -1){
			ir(nextL);
			temp = pos;
			ir(startTo[pos]);
			startTo[temp] = -1;
			continue;
		}
		ans+= pos;
		return ans;
	}
	
}

Compilation message

books.cpp:30:36: error: wrong number of template arguments (0, should be at least 1)
   30 | long long minimum_walk(std::vector<> p, int s) {
      |                                    ^
In file included from /usr/include/c++/10/vector:67,
                 from books.h:1,
                 from books.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:389:11: note: provided for 'template<class _Tp, class _Alloc> class std::vector'
  389 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
books.cpp: In function 'long long int minimum_walk(int, int)':
books.cpp:31:8: error: request for member 'size' in 'p', which is of non-class type 'int'
   31 |  n = p.size();int
      |        ^~~~
books.cpp:32:2: error: expected unqualified-id before 'for'
   32 |  for(int i = 0 ; i < n ; i ++){
      |  ^~~
books.cpp:32:18: error: 'i' was not declared in this scope
   32 |  for(int i = 0 ; i < n ; i ++){
      |                  ^