Submission #405733

# Submission time Handle Problem Language Result Execution time Memory
405733 2021-05-16T20:56:36 Z ly20 Stations (IOI20_stations) C++17
Compilation error
0 ms 0 KB
#include "stations.h"
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1123;
int t, ent[MAXN], sd[MAXN], prof[MAXN];
vector <int> grafo[MAXN];
void dfs(int v, int p) {
    ent[v] = t;
    t++;
    for(int i = 0; i < grafo[v].size(); i++) {
        int viz = grafo[v][i];
        if(viz == p) continue;
        prof[viz] = prof[v] + 1;
        dfs(viz, v);
    }
    sd[v] = t;
    t++;
}
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
	vector<int> labels;
    for(int i = 0; i < n; i++) {
        grafo[u[i]].push_back(v[i]);
        grafo[v[i]].push_back(u[i]);
    }
    dfs(0, 0);
    set <pair <int, int> > s;
    map <pair <int, int>, int> mp;
	for (int i = 0; i < n; i++) {
		if(prof[i] % 2 == 0) s.insert(make_pair(ent[i], 0));
		else s.insert(make_pair(sd[i], 1));
	}
	int at = 0;
	set <pair <int, int> > :: iterator it;
	for(it = s.begin(); it != s.end(); it++) {
        mp[*it] = at++;
	}
    for(int i  = 0; i < n; i++) {
        pair a;
        if(prof[i] % 2 == 0) a = make_pair(ent[i], 0);
        else a = make_pair(sd[i], 1);
        labels.push_back(mp[a]);
    }
	return labels;
}

int find_next_station(int s, int t, vector<int> c) {
	int tp, rs, mn = 1123, mx = 0;
	if(c.size() == 1) return c[0];
	for(int i = 0; i < c.size(); i++) {
        int viz = c[i];
        mn = min(viz, mn);
        mx = max(viz, mx);
        if(viz < s) tp = 1;
        if(viz > s) tp = 0;
	}
	vector <int> temp;
	if(tp == 0) {
        rs = mx;
        temp.push_back(s);
        for(int i = 0; i < c[i].size(); i++) {
            if(c[i] == mx) {
                mx = -mx;
                continue;
            }
            temp.push_back(c[i]);
        }
        sort(temp.begin(), temp.end());
        for(int i = 1; i < temp.size(); i++) {
            if(t >= temp[i - 1] + 1 && t <= temp[i]) {
                rs = temp[i];
            }
        }
	}
	else {
        rs = mn;
        temp.push_back(s);
        for(int i = 0; i < c[i].size(); i++) {
            if(c[i] == mn) {
                mn = -mn;
                continue;
            }
            temp.push_back(c[i]);
        }
        sort(temp.begin(), temp.end());
        for(int i = 0; i < temp.size() - 1; i++) {
            if(t >= temp[i] && t <= temp[i + 1] + 1) {
                rs = temp[i];
            }
        }
	}
    return rs;
}

Compilation message

stations.cpp: In function 'void dfs(int, int)':
stations.cpp:10:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |     for(int i = 0; i < grafo[v].size(); i++) {
      |                    ~~^~~~~~~~~~~~~~~~~
stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:38:14: error: class template argument deduction failed:
   38 |         pair a;
      |              ^
stations.cpp:38:14: error: no matching function for call to 'pair()'
In file included from /usr/include/c++/10/functional:54,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from stations.cpp:2:
/usr/include/c++/10/tuple:1685:7: note: candidate: 'template<class _T1, class _T2, class ... _Args1, long unsigned int ..._Indexes1, class ... _Args2, long unsigned int ..._Indexes2> pair(std::tuple<_Tail ...>&, std::tuple<_Args2 ...>&, std::_Index_tuple<_Indexes2 ...>, std::_Index_tuple<_Indexes2 ...>)-> std::pair<_T1, _T2>'
 1685 |       pair<_T1, _T2>::
      |       ^~~~~~~~~~~~~~
/usr/include/c++/10/tuple:1685:7: note:   template argument deduction/substitution failed:
stations.cpp:38:14: note:   candidate expects 4 arguments, 0 provided
   38 |         pair a;
      |              ^
In file included from /usr/include/c++/10/functional:54,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from stations.cpp:2:
/usr/include/c++/10/tuple:1673:7: note: candidate: 'template<class _T1, class _T2, class ... _Args1, class ... _Args2> pair(std::piecewise_construct_t, std::tuple<_Tail ...>, std::tuple<_Args2 ...>)-> std::pair<_T1, _T2>'
 1673 |       pair<_T1, _T2>::
      |       ^~~~~~~~~~~~~~
/usr/include/c++/10/tuple:1673:7: note:   template argument deduction/substitution failed:
stations.cpp:38:14: note:   candidate expects 3 arguments, 0 provided
   38 |         pair a;
      |              ^
In file included from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/vector:60,
                 from stations.h:1,
                 from stations.cpp:1:
/usr/include/c++/10/bits/stl_pair.h:381:21: note: candidate: 'template<class _T1, class _T2, class _U1, class _U2, typename std::enable_if<(std::_PCC<((! std::is_same<_T1, _U1>::value) || (! std::is_same<_T2, _U2>::value)), _T1, _T2>::_MoveConstructiblePair<_U1, _U2>() && (! std::_PCC<((! std::is_same<_T1, _U1>::value) || (! std::is_same<_T2, _U2>::value)), _T1, _T2>::_ImplicitlyMoveConvertiblePair<_U1, _U2>())), bool>::type <anonymous> > pair(std::pair<_ForwardIterator1, _ForwardIterator2>&&)-> std::pair<_T1, _T2>'
  381 |  explicit constexpr pair(pair<_U1, _U2>&& __p)
      |                     ^~~~
/usr/include/c++/10/bits/stl_pair.h:381:21: note:   template argument deduction/substitution failed:
stations.cpp:38:14: note:   candidate expects 1 argument, 0 provided
   38 |         pair a;
      |              ^
In file included from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/vector:60,
                 from stations.h:1,
                 from stations.cpp:1:
/usr/include/c++/10/bits/stl_pair.h:371:12: note: candidate: 'template<class _T1, class _T2, class _U1, class _U2, typename std::enable_if<(std::_PCC<((! std::is_same<_T1, _U1>::value) || (! std::is_same<_T2, _U2>::value)), _T1, _T2>::_MoveConstructiblePair<_U1, _U2>() && std::_PCC<((! std::is_same<_T1, _U1>::value) || (! std::is_same<_T2, _U2>::value)), _T1, _T2>::_ImplicitlyMoveConvertiblePair<_U1, _U2>()), bool>::type <anonymous> > pair(std::pair<_ForwardIterator1, _ForwardIterator2>&&)-> std::pair<_T1, _T2>'
  371 |  constexpr pair(pair<_U1, _U2>&& __p)
      |            ^~~~
/usr/include/c++/10/bits/stl_pair.h:371:12: note:   template argument deduction/substitution failed:
stations.cpp:38:14: note:   candidate expects 1 argument, 0 provided
   38 |         pair a;
      |              ^
In file included from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/vector:60,
                 from stations.h:1,
                 from stations.cpp:1:
/usr/include/c++/10/bits/stl_pair.h:361:21: note: candidate: 'template<class _T1, class _T2, class _U1, class _U2, typename std::enable_if<(std::_PCC<true, _T1, _T2>::_MoveConstructiblePair<_U1, _U2>() && (! std::_PCC<true, _T1, _T2>::_ImplicitlyMoveConvertiblePair<_U1, _U2>())), bool>::type <anonymous> > pair(_U1&&, _U2&&)-> std::pair<_T1, _T2>'
  361 |  explicit constexpr pair(_U1&& __x, _U2&& __y)
      |                     ^~~~
/usr/include/c++/10/bits/stl_pair.h:361:21: note:   template argument deduction/substitution failed:
stations.cpp:38:14: note:   candidate expects 2 arguments, 0 provided
   38 |         pair a;
      |              ^
In file included from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/vector:60,
                 from stations.h:1,
                 from stations.cpp:1:
/usr/include/c++/10/bits/stl_pair.h:352:12: note: candidate: 'template<class _T1, class _T2, class _U1, class _U2, typename std::enable_if<(std::_PCC<true, _T1, _T2>::_MoveConstructiblePair<_U1, _U2>() && std::_PCC<true, _T1, _T2>::_ImplicitlyMoveConvertiblePair<_U1, _U2>()), bool>::type <anonymous> > pair(_U1&&, _U2&&)-> std::pair<_T1, _T2>'
  352 |  constexpr pair(_U1&& __x, _U2&& __y)
      |            ^~~~
/usr/include/c++/10/bits/stl_pair.h:352:12: note:   template argument deduction/substitution failed:
stations.cpp:38:14: note:   candidate expects 2 arguments, 0 provided
   38 |         pair a;
      |              ^
In file included from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/vector:60,
                 from stations.h:1,
                 from stations.cpp:1:
/usr/include/c++/10/bits/stl_pair.h:343:17: note: candidate: 'template<class _T1, class _T2, class _U2, typename std::enable_if<std::_PCC<true, _T1, _T2>::_CopyMovePair<false, _T1, _U2>(), bool>::type <anonymous> > pair(const _T1&, _U2&&)-> std::pair<_T1, _T2>'
  343 |        explicit pair(const _T1& __x, _U2&& __y)
      |                 ^~~~
/usr/include/c++/10/bits/stl_pair.h:343:17: note:   template argument deduction/substitution failed:
stations.cpp:38:14: note:   candidate expects 2 arguments, 0 provided
   38 |         pair a;
      |              ^
In file included from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/vector:60,
                 from stations.h:1,
                 from stations.cpp:1:
/usr/include/c++/10/bits/stl_pair.h:336:18: note: candidate: 'template<class _T1, class _T2, class _U2, typename std::enable_if<std::_PCC<true, _T1, _T2>::_CopyMovePair<true, _T1, _U2>(), bool>::type <anonymous> > pair(const _T1&, _U2&&)-> std::pair<_T1, _T2>'
  336 |        constexpr pair(const _T1& __x, _U2&& __y)
      |                  ^~~~
/usr/include/c++/10/bits/stl_pair.h:336:18: note:   template argument deduction/substitution failed:
stations.cpp:38:14: note:   candidate expects 2 arguments, 0 provided
   38 |         pair a;
      |              ^
In file included from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/vector:60,
                 from stations.h:1,
                 from stations.cpp:1:
/usr/include/c++/10/bits/stl_pair.h:329:27: note: candidate: 'template<class _T1, class _T2, class _U1, typename std::enable_if<std::_PCC<true, _T1, _T2>::_MoveCopyPair<false, _U1, _T2>(), bool>::type <anonymous> > pair(_U1&&, const _T2&)-> std::pair<_T1, _T2>'
  329 |        explicit constexpr pair(_U1&& __x, const _T2& __y)
      |                           ^~~~
/usr/include/c++/10/bits/stl_pair.h:329:27: note:   template argument deduction/substitution failed:
stations.cpp:38:14: note:   candidate expects 2 arguments, 0 provided
   38 |         pair a;
      |              ^
In file included from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/vector:60,
                 from stations.h:1,
                 from stations.cpp:1:
/usr/include/c++/10/bits/stl_pair.h:322:18: note: candidate: 'template<class _T1, class _T2, class _U1, typename std::enable_if<std::_PCC<true, _T1, _T2>::_MoveCopyPair<true, _U1, _T2>(), bool>::type <anonymous> > pair(_U1&&, const _T2&)-> std::pair<_T1, _T2>'
  322 |        constexpr pair(_U1&& __x, const _T2& __y)
      |                  ^~~~
/usr/include/c++/10/bits/stl_pair.h:322:18: note:   template argument deduction/substitution failed:
stations.cpp:38:14: note:   candidate expects 2 arguments, 0 provided
   38 |         pair a;
      |              ^
In file included from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/vector:60,
                 from stations.h:1,
                 from stations.cpp:1:
/usr/include/c++/10/bits/stl_pair.h:315:17: note: candidate: 'template<class _T1, class _T2> pair(std::pair<_T1, _T2>&&)-> std::pair<_T1, _T2>'
  315 |       constexpr pair(pair&&) = default;  ///< Move constructor
      |                 ^~~~
/usr/include/c++/10/bits/stl_pair.h:315:17: note:   template argument deduction/substitution failed:
stations.cpp:38:14: note:   candidate expects 1 argument, 0 provided
   38 |         pair a;
      |              ^
In file included from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/vector:60,
                 from stations.h:1,
                 from stations.cpp:1:
/usr/include/c++/10/bits/stl_pair.h:314:17: note: candidate: 'template<class _T1, class _T2> pair(const std::pair<_T1, _T2>&)-> std::pair<_T1, _T2>'
  314 |       constexpr pair(const pair&) = default; ///< Copy constructor
      |                 ^~~~
/usr/include/c++/10/bits/stl_pair.h:314:17: note:   template argument deduction/substitution failed:
stations.cpp:38:14: note:   candidate expects 1 argument, 0 provided
   38 |         pair a;
      |              ^
In file included from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/vector:60,
                 from stations.h:1,
                 from stations.cpp:1:
/usr/include/c++/10/bits/stl_pair.h:309:21: note: candidate: 'template<class _T1, class _T2, class _U1, class _U2, typename std::enable_if<(std::_PCC<((! std::is_same<_T1, _U1>::value) || (! std::is_same<_T2, _U2>::value)), _T1, _T2>::_ConstructiblePair<_U1, _U2>() && (! std::_PCC<((! std::is_same<_T1, _U1>::value) || (! std::is_same<_T2, _U2>::value)), _T1, _T2>::_ImplicitlyConvertiblePair<_U1, _U2>())), bool>::type <anonymous> > pair(const std::pair<_ForwardIterator1, _ForwardIterator2>&)-> std::pair<_T1, _T2>'
  309 |  explicit constexpr pair(const pair<_U1, _U2>& __p)
      |                     ^~~~
/usr/include/c++/10/bits/stl_pair.h:309:21: note:   template argument deduction/substitution failed:
stations.cpp:38:14: note:   candidate expects 1 argument, 0 provided
   38 |         pair a;
      |              ^
In file included from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/vector:60,
                 from stations.h:1,
                 from stations.cpp:1:
/usr/include/c++/10/bits/stl_pair.h:300:19: note: candidate: 'template<class _T1, class _T2, class _U1, class _U2, typename std::enable_if<(std::_PCC<((! std::is_same<_T1, _U1>::value) || (! std::is_same<_T2, _U2>::value)), _T1, _T2>::_ConstructiblePair<_U1, _U2>() && std::_PCC<((! std::is_same<_T1, _U1>::value) || (! std::is_same<_T2, _U2>::value)), _T1, _T2>::_ImplicitlyConvertiblePair<_U1, _U2>()), bool>::type <anonymous> > pair(const std::pair<_ForwardIterator1, _ForwardIterator2>&)-> std::pair<_T1, _T2>'
  300 |         constexpr pair(const pair<_U1, _U2>& __p)
      |                   ^~~~
/usr/include/c++/10/bits/stl_pair.h:300:19: note:   template argument deduction/substitution failed:
stations.cpp:38:14: note:   candidate expects 1 argument, 0 provided
   38 |         pair a;
      |              ^
In file included from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/vector:60,
                 from stations.h:1,
                 from stations.cpp:1:
/usr/include/c++/10/bits/stl_pair.h:276:26: note: candidate: 'template<class _T1, class _T2, class _U1, class _U2, typename std::enable_if<(std::_PCC<true, _T1, _T2>::_ConstructiblePair<_U1, _U2>() && (! std::_PCC<true, _T1, _T2>::_ImplicitlyConvertiblePair<_U1, _U2>())), bool>::type <anonymous> > pair(const _T1&, const _T2&)-> std::pair<_T1, _T2>'
  276 |       explicit constexpr pair(const _T1& __a, const _T2& __b)
      |                          ^~~~
/usr/include/c++/10/bits/stl_pair.h:276:26: note:   template argument deduction/substitution failed:
stations.cpp:38:14: note:   candidate expects 2 arguments, 0 provided
   38 |         pair a;
      |              ^
In file included from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/vector:60,
                 from stations.h:1,
                 from stations.cpp:1:
/usr/include/c++/10/bits/stl_pair.h:266:17: note: candidate: 'template<class _T1, class _T2, class _U1, class _U2, typename std::enable_if<(std::_PCC<true, _T1, _T2>::_ConstructiblePair<_U1, _U2>() && std::_PCC<true, _T1, _T2>::_ImplicitlyConvertiblePair<_U1, _U2>()), bool>::type <anonymous> > pair(const _T1&, const _T2&)-> std::pair<_T1, _T2>'
  266 |       constexpr pair(const _T1& __a, const _T2& __b)
      |                 ^~~~
/usr/include/c++/10/bits/stl_pair.h:266:17: note:   template argument deduction/substitution failed:
stations.cpp:38:14: note:   candidate expects 2 arguments, 0 provided
   38 |         pair a;
      |              ^
In file included from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/vector:60,
                 from stations.h:1,
                 from stations.cpp:1:
/usr/include/c++/10/bits/stl_pair.h:245:26: note: candidate: 'template<class _T1, class _T2, class _U1, class _U2, typename std::enable_if<std::__and_<std::is_default_constructible<_Compare>, std::is_default_constructible<_U2>, std::__not_<std::__and_<std::__is_implicitly_default_constructible<_U1>, std::__is_implicitly_default_constructible<_U2> > > >::value, bool>::type <anonymous> > pair()-> std::pair<_T1, _T2>'
  245 |       explicit constexpr pair()
      |                          ^~~~
/usr/include/c++/10/bits/stl_pair.h:245:26: note:   template argument deduction/substitution failed:
stations.cpp:38:14: note:   couldn't deduce template parameter '_T1'
   38 |         pair a;
      |              ^
In file included from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/vector:60,
                 from stations.h:1,
                 from stations.cpp:1:
/usr/include/c++/10/bits/stl_pair.h:232:26: note: candidate: 'template<class _T1, class _T2, class _U1, class _U2, typename std::enable_if<std::__and_<std::__is_implicitly_default_constructible<_U1>, std::__is_implicitly_default_constructible<_U2> >::value, bool>::type <anonymous> > pair()-> std::pair<_T1, _T2>'
  232 |       _GLIBCXX_CONSTEXPR pair()
      |                          ^~~~
/usr/include/c++/10/bits/stl_pair.h:232:26: note:   template argument deduction/substitution failed:
stations.cpp:38:14: note:   couldn't deduce template parameter '_T1'
   38 |         pair a;
      |              ^
In file included from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/vector:60,
                 from stations.h:1,
                 from stations.cpp:1:
/usr/include/c++/10/bits/stl_pair.h:211:12: note: candidate: 'template<class _T1, class _T2> pair(std::pair<_T1, _T2>)-> std::pair<_T1, _T2>'
  211 |     struct pair
      |            ^~~~
/usr/include/c++/10/bits/stl_pair.h:211:12: note:   template argument deduction/substitution failed:
stations.cpp:38:14: note:   candidate expects 1 argument, 0 provided
   38 |         pair a;
      |              ^
In file included from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/vector:60,
                 from stations.h:1,
                 from stations.cpp:1:
/usr/include/c++/10/bits/stl_pair.h:460:40: note: candidate: 'template<class _T1, class _T2> std::pair(_T1, _T2)-> std::pair<_T1, _T2>'
  460 |   template<typename _T1, typename _T2> pair(_T1, _T2) -> pair<_T1, _T2>;
      |                                        ^~~~
/usr/include/c++/10/bits/stl_pair.h:460:40: note:   template argument deduction/substitution failed:
stations.cpp:38:14: note:   candidate expects 2 arguments, 0 provided
   38 |         pair a;
      |              ^
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:49:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |  for(int i = 0; i < c.size(); i++) {
      |                 ~~^~~~~~~~~~
stations.cpp:60:33: error: request for member 'size' in 'c.std::vector<int>::operator[](((std::vector<int>::size_type)i))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   60 |         for(int i = 0; i < c[i].size(); i++) {
      |                                 ^~~~
stations.cpp:68:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   68 |         for(int i = 1; i < temp.size(); i++) {
      |                        ~~^~~~~~~~~~~~~
stations.cpp:77:33: error: request for mem