Submission #530690

# Submission time Handle Problem Language Result Execution time Memory
530690 2022-02-26T12:31:41 Z Icebear16 Fountain Parks (IOI21_parks) C++17
Compilation error
0 ms 0 KB
#include "parks.h"
#include <bits/stdc++.h>
int construct_roads(std::vector<int> x, std::vector<int> y) {
    if (x.size() == 1) {
	build({}, {}, {}, {});
        return 1;
    }else{
	    std::vector<int> u, v, a, b;
	    bool flag=true;
	    std::vector<pair<int,int>> p;
	    for(int i=0;i<x.size();i++){
	    	p.push_back(make_pair(y[i],i));
		}
	    sort(p.begin(),p.end());
	    for(int i=1;i<x.size();i++){
	    	if(p[i].first%2==1 || p[i].first-y[i-1].first!=2){
	    		flag=false;
	    		break;
			}
		}
		if(flag==true){
			for(int i=0;i<x.size()-1;i++){
		    	u.push_back(p[i].second);
		    	v.push_back(p[i+1].second);
			    a.push_back(x[i]+1);
		    	b.push_back(p[i].first+1);
			}
		    build(u, v, a, b);
		    return 1;
		}else{
			return 0;
		}
	}
}

Compilation message

parks.cpp: In function 'int construct_roads(std::vector<int>, std::vector<int>)':
parks.cpp:10:18: error: 'pair' was not declared in this scope; did you mean 'std::pair'?
   10 |      std::vector<pair<int,int>> p;
      |                  ^~~~
      |                  std::pair
In file included from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/vector:60,
                 from parks.h:1,
                 from parks.cpp:1:
/usr/include/c++/10/bits/stl_pair.h:211:12: note: 'std::pair' declared here
  211 |     struct pair
      |            ^~~~
parks.cpp:10:30: error: template argument 1 is invalid
   10 |      std::vector<pair<int,int>> p;
      |                              ^~
parks.cpp:10:30: error: template argument 2 is invalid
parks.cpp:11:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |      for(int i=0;i<x.size();i++){
      |                  ~^~~~~~~~~
parks.cpp:12:9: error: request for member 'push_back' in 'p', which is of non-class type 'int'
   12 |       p.push_back(make_pair(y[i],i));
      |         ^~~~~~~~~
parks.cpp:12:19: error: 'make_pair' was not declared in this scope; did you mean 'std::make_pair'?
   12 |       p.push_back(make_pair(y[i],i));
      |                   ^~~~~~~~~
      |                   std::make_pair
In file included from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/vector:60,
                 from parks.h:1,
                 from parks.cpp:1:
/usr/include/c++/10/bits/stl_pair.h:567:5: note: 'std::make_pair' declared here
  567 |     make_pair(_T1&& __x, _T2&& __y)
      |     ^~~~~~~~~
parks.cpp:14:13: error: request for member 'begin' in 'p', which is of non-class type 'int'
   14 |      sort(p.begin(),p.end());
      |             ^~~~~
parks.cpp:14:23: error: request for member 'end' in 'p', which is of non-class type 'int'
   14 |      sort(p.begin(),p.end());
      |                       ^~~
parks.cpp:14:6: error: 'sort' was not declared in this scope; did you mean 'std::sort'?
   14 |      sort(p.begin(),p.end());
      |      ^~~~
      |      std::sort
In file included from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from parks.cpp:2:
/usr/include/c++/10/pstl/glue_algorithm_defs.h:296:1: note: 'std::sort' declared here
  296 | sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last);
      | ^~~~
parks.cpp:15:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |      for(int i=1;i<x.size();i++){
      |                  ~^~~~~~~~~
parks.cpp:16:11: error: invalid types 'int[int]' for array subscript
   16 |       if(p[i].first%2==1 || p[i].first-y[i-1].first!=2){
      |           ^
parks.cpp:16:30: error: invalid types 'int[int]' for array subscript
   16 |       if(p[i].first%2==1 || p[i].first-y[i-1].first!=2){
      |                              ^
parks.cpp:16:47: error: request for member 'first' in 'y.std::vector<int>::operator[](((std::vector<int>::size_type)(i - 1)))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   16 |       if(p[i].first%2==1 || p[i].first-y[i-1].first!=2){
      |                                               ^~~~~
parks.cpp:22:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |    for(int i=0;i<x.size()-1;i++){
      |                ~^~~~~~~~~~~
parks.cpp:23:21: error: invalid types 'int[int]' for array subscript
   23 |        u.push_back(p[i].second);
      |                     ^
parks.cpp:24:21: error: invalid types 'int[int]' for array subscript
   24 |        v.push_back(p[i+1].second);
      |                     ^
parks.cpp:26:21: error: invalid types 'int[int]' for array subscript
   26 |        b.push_back(p[i].first+1);
      |                     ^