답안 #124864

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
124864 2019-07-04T04:52:15 Z khulegub 곤돌라 (IOI14_gondola) C++14
컴파일 오류
0 ms 0 KB
#include "gondola.h"
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define xx first
#define yy second
using namespace std;
typedef long long i64;
typedef pair<int, int> pii;




int valid(int n, int arr[]){
	vector<int> rep;
	vector<int> v;
	for (int i = 0; i < n; i++){
		arr[i]--;
		if (arr[i] > n){
			rep.pb(mp(i, arr[i] - n) );
		}
		else v.pb(mp(i, arr[i]) );
	}
	if(v.size() > 0){
		int diff = v[0].yy - v[0].xx;
		int end = (n - 1) + diff;
		int diff2 = n + diff;
		int vn = v.size();
		for (int i = 0; i < vn; i++){
			if (v[i].xx <= end){
				if (v[i].yy - v[i].xx != diff) return 0;
			}
			else{
				if (v[i].yy - v[i].xx != diff2) return 0;
			}
		}
	}
	return 1;
}

//----------------------

int replacement(int n, int gondolaSeq[], int replacementSeq[])
{
  return -2;
}

//----------------------

int countReplacement(int n, int inputSeq[])
{
  return -3;
}

Compilation message

gondola.cpp: In function 'int valid(int, int*)':
gondola.cpp:20:29: error: no matching function for call to 'std::vector<int>::push_back(std::pair<int, int>)'
    rep.pb(mp(i, arr[i] - n) );
                             ^
In file included from /usr/include/c++/7/vector:64:0,
                 from /usr/include/c++/7/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:86,
                 from gondola.cpp:2:
/usr/include/c++/7/bits/stl_vector.h:939:7: note: candidate: void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::value_type = int]
       push_back(const value_type& __x)
       ^~~~~~~~~
/usr/include/c++/7/bits/stl_vector.h:939:7: note:   no known conversion for argument 1 from 'std::pair<int, int>' to 'const value_type& {aka const int&}'
/usr/include/c++/7/bits/stl_vector.h:953:7: note: candidate: void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::value_type = int]
       push_back(value_type&& __x)
       ^~~~~~~~~
/usr/include/c++/7/bits/stl_vector.h:953:7: note:   no known conversion for argument 1 from 'std::pair<int, int>' to 'std::vector<int>::value_type&& {aka int&&}'
gondola.cpp:22:27: error: no matching function for call to 'std::vector<int>::push_back(std::pair<int, int>)'
   else v.pb(mp(i, arr[i]) );
                           ^
In file included from /usr/include/c++/7/vector:64:0,
                 from /usr/include/c++/7/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:86,
                 from gondola.cpp:2:
/usr/include/c++/7/bits/stl_vector.h:939:7: note: candidate: void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::value_type = int]
       push_back(const value_type& __x)
       ^~~~~~~~~
/usr/include/c++/7/bits/stl_vector.h:939:7: note:   no known conversion for argument 1 from 'std::pair<int, int>' to 'const value_type& {aka const int&}'
/usr/include/c++/7/bits/stl_vector.h:953:7: note: candidate: void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::value_type = int]
       push_back(value_type&& __x)
       ^~~~~~~~~
/usr/include/c++/7/bits/stl_vector.h:953:7: note:   no known conversion for argument 1 from 'std::pair<int, int>' to 'std::vector<int>::value_type&& {aka int&&}'
gondola.cpp:6:12: error: request for member 'second' in 'v.std::vector<int>::operator[](0)', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int> >::value_type {aka int}'
 #define yy second
            ^
gondola.cpp:25:19: note: in expansion of macro 'yy'
   int diff = v[0].yy - v[0].xx;
                   ^~
gondola.cpp:5:12: error: request for member 'first' in 'v.std::vector<int>::operator[](0)', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int> >::value_type {aka int}'
 #define xx first
            ^
gondola.cpp:25:29: note: in expansion of macro 'xx'
   int diff = v[0].yy - v[0].xx;
                             ^~
gondola.cpp:5:12: error: request for member 'first' in 'v.std::vector<int>::operator[](((std::vector<int>::size_type)i))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int> >::value_type {aka int}'
 #define xx first
            ^
gondola.cpp:30:13: note: in expansion of macro 'xx'
    if (v[i].xx <= end){
             ^~
gondola.cpp:6:12: error: request for member 'second' in 'v.std::vector<int>::operator[](((std::vector<int>::size_type)i))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int> >::value_type {aka int}'
 #define yy second
            ^
gondola.cpp:31:14: note: in expansion of macro 'yy'
     if (v[i].yy - v[i].xx != diff) return 0;
              ^~
gondola.cpp:5:12: error: request for member 'first' in 'v.std::vector<int>::operator[](((std::vector<int>::size_type)i))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int> >::value_type {aka int}'
 #define xx first
            ^
gondola.cpp:31:24: note: in expansion of macro 'xx'
     if (v[i].yy - v[i].xx != diff) return 0;
                        ^~
gondola.cpp:6:12: error: request for member 'second' in 'v.std::vector<int>::operator[](((std::vector<int>::size_type)i))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int> >::value_type {aka int}'
 #define yy second
            ^
gondola.cpp:34:14: note: in expansion of macro 'yy'
     if (v[i].yy - v[i].xx != diff2) return 0;
              ^~
gondola.cpp:5:12: error: request for member 'first' in 'v.std::vector<int>::operator[](((std::vector<int>::size_type)i))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int> >::value_type {aka int}'
 #define xx first
            ^
gondola.cpp:34:24: note: in expansion of macro 'xx'
     if (v[i].yy - v[i].xx != diff2) return 0;
                        ^~