fork(1) download
  1. #include <iostream>
  2. #include <map>
  3. #include <vector>
  4. #include <string>
  5. #include <algorithm>
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10. map<string,vector<int>> countriesAndYears;
  11.  
  12. int n;
  13. string country;
  14. int year,visit;
  15. cin >> n;
  16. for(int i=0;i<n;++i)
  17. {
  18. cin >> country >> year;
  19. countriesAndYears[country].push_back(year);
  20. }
  21. for (const auto& elem : countriesAndYears)
  22. {
  23. sort(elem.second.begin(),elem.second.end());
  24. }
  25. cin >> n;
  26. for(int i=0;i<n;++i)
  27. {
  28. cin >> country >> visit;
  29. cout << countriesAndYears[country][visit-1] << "\n";
  30. }
  31. return 0;
  32. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
4
Iceland 2014
Iceland 2015
Iceland 2015
Iceland 2016
4
Iceland 4
Iceland 3
Iceland 2
Iceland 1
compilation info
In file included from /usr/include/c++/6/algorithm:62:0,
                 from prog.cpp:5:
/usr/include/c++/6/bits/stl_algo.h: In instantiation of ‘void std::__insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<const int*, std::vector<int> >; _Compare = __gnu_cxx::__ops::_Iter_less_iter]’:
/usr/include/c++/6/bits/stl_algo.h:1882:25:   required from ‘void std::__final_insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<const int*, std::vector<int> >; _Compare = __gnu_cxx::__ops::_Iter_less_iter]’
/usr/include/c++/6/bits/stl_algo.h:1968:31:   required from ‘void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<const int*, std::vector<int> >; _Compare = __gnu_cxx::__ops::_Iter_less_iter]’
/usr/include/c++/6/bits/stl_algo.h:4707:18:   required from ‘void std::sort(_RAIter, _RAIter) [with _RAIter = __gnu_cxx::__normal_iterator<const int*, std::vector<int> >]’
prog.cpp:23:45:   required from here
/usr/include/c++/6/bits/stl_algo.h:1849:17: error: assignment of read-only location ‘__first.__gnu_cxx::__normal_iterator<_Iterator, _Container>::operator*<const int*, std::vector<int> >()’
        *__first = _GLIBCXX_MOVE(__val);
                 ^
In file included from /usr/include/c++/6/bits/stl_algo.h:61:0,
                 from /usr/include/c++/6/algorithm:62,
                 from prog.cpp:5:
/usr/include/c++/6/bits/stl_heap.h: In instantiation of ‘void std::__pop_heap(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<const int*, std::vector<int> >; _Compare = __gnu_cxx::__ops::_Iter_less_iter]’:
/usr/include/c++/6/bits/stl_algo.h:1672:19:   required from ‘void std::__heap_select(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<const int*, std::vector<int> >; _Compare = __gnu_cxx::__ops::_Iter_less_iter]’
/usr/include/c++/6/bits/stl_algo.h:1930:25:   required from ‘void std::__partial_sort(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<const int*, std::vector<int> >; _Compare = __gnu_cxx::__ops::_Iter_less_iter]’
/usr/include/c++/6/bits/stl_algo.h:1945:27:   required from ‘void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<const int*, std::vector<int> >; _Size = long int; _Compare = __gnu_cxx::__ops::_Iter_less_iter]’
/usr/include/c++/6/bits/stl_algo.h:1965:25:   required from ‘void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<const int*, std::vector<int> >; _Compare = __gnu_cxx::__ops::_Iter_less_iter]’
/usr/include/c++/6/bits/stl_algo.h:4707:18:   required from ‘void std::sort(_RAIter, _RAIter) [with _RAIter = __gnu_cxx::__normal_iterator<const int*, std::vector<int> >]’
prog.cpp:23:45:   required from here
/usr/include/c++/6/bits/stl_heap.h:246:17: error: assignment of read-only location ‘__result.__gnu_cxx::__normal_iterator<_Iterator, _Container>::operator*<const int*, std::vector<int> >()’
       *__result = _GLIBCXX_MOVE(*__first);
                 ^
In file included from /usr/include/c++/6/bits/char_traits.h:39:0,
                 from /usr/include/c++/6/ios:40,
                 from /usr/include/c++/6/ostream:38,
                 from /usr/include/c++/6/iostream:39,
                 from prog.cpp:1:
/usr/include/c++/6/bits/stl_algobase.h: In instantiation of ‘void std::iter_swap(_ForwardIterator1, _ForwardIterator2) [with _ForwardIterator1 = __gnu_cxx::__normal_iterator<const int*, std::vector<int> >; _ForwardIterator2 = __gnu_cxx::__normal_iterator<const int*, std::vector<int> >]’:
/usr/include/c++/6/bits/stl_algo.h:84:20:   required from ‘void std::__move_median_to_first(_Iterator, _Iterator, _Iterator, _Iterator, _Compare) [with _Iterator = __gnu_cxx::__normal_iterator<const int*, std::vector<int> >; _Compare = __gnu_cxx::__ops::_Iter_less_iter]’
/usr/include/c++/6/bits/stl_algo.h:1918:34:   required from ‘_RandomAccessIterator std::__unguarded_partition_pivot(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<const int*, std::vector<int> >; _Compare = __gnu_cxx::__ops::_Iter_less_iter]’
/usr/include/c++/6/bits/stl_algo.h:1950:38:   required from ‘void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<const int*, std::vector<int> >; _Size = long int; _Compare = __gnu_cxx::__ops::_Iter_less_iter]’
/usr/include/c++/6/bits/stl_algo.h:1965:25:   required from ‘void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<const int*, std::vector<int> >; _Compare = __gnu_cxx::__ops::_Iter_less_iter]’
/usr/include/c++/6/bits/stl_algo.h:4707:18:   required from ‘void std::sort(_RAIter, _RAIter) [with _RAIter = __gnu_cxx::__normal_iterator<const int*, std::vector<int> >]’
prog.cpp:23:45:   required from here
/usr/include/c++/6/bits/stl_algobase.h:148:11: error: no matching function for call to ‘swap(const int&, const int&)’
       swap(*__a, *__b);
       ~~~~^~~~~~~~~~~~
In file included from /usr/include/c++/6/bits/nested_exception.h:40:0,
                 from /usr/include/c++/6/exception:173,
                 from /usr/include/c++/6/ios:39,
                 from /usr/include/c++/6/ostream:38,
                 from /usr/include/c++/6/iostream:39,
                 from prog.cpp:1:
/usr/include/c++/6/bits/move.h:179:5: note: candidate: template<class _Tp> typename std::enable_if<std::__and_<std::is_move_constructible<_Tp>, std::is_move_assignable<_Tp> >::value>::type std::swap(_Tp&, _Tp&)
     swap(_Tp& __a, _Tp& __b)
     ^~~~
/usr/include/c++/6/bits/move.h:179:5: note:   template argument deduction/substitution failed:
/usr/include/c++/6/bits/move.h: In substitution of ‘template<class _Tp> typename std::enable_if<std::__and_<std::is_move_constructible<_Tp>, std::is_move_assignable<_Tp> >::value>::type std::swap(_Tp&, _Tp&) [with _Tp = const int]’:
/usr/include/c++/6/bits/stl_algobase.h:148:11:   required from ‘void std::iter_swap(_ForwardIterator1, _ForwardIterator2) [with _ForwardIterator1 = __gnu_cxx::__normal_iterator<const int*, std::vector<int> >; _ForwardIterator2 = __gnu_cxx::__normal_iterator<const int*, std::vector<int> >]’
/usr/include/c++/6/bits/stl_algo.h:84:20:   required from ‘void std::__move_median_to_first(_Iterator, _Iterator, _Iterator, _Iterator, _Compare) [with _Iterator = __gnu_cxx::__normal_iterator<const int*, std::vector<int> >; _Compare = __gnu_cxx::__ops::_Iter_less_iter]’
/usr/include/c++/6/bits/stl_algo.h:1918:34:   required from ‘_RandomAccessIterator std::__unguarded_partition_pivot(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<const int*, std::vector<int> >; _Compare = __gnu_cxx::__ops::_Iter_less_iter]’
/usr/include/c++/6/bits/stl_algo.h:1950:38:   required from ‘void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<const int*, std::vector<int> >; _Size = long int; _Compare = __gnu_cxx::__ops::_Iter_less_iter]’
/usr/include/c++/6/bits/stl_algo.h:1965:25:   required from ‘void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<const int*, std::vector<int> >; _Compare = __gnu_cxx::__ops::_Iter_less_iter]’
/usr/include/c++/6/bits/stl_algo.h:4707:18:   required from ‘void std::sort(_RAIter, _RAIter) [with _RAIter = __gnu_cxx::__normal_iterator<const int*, std::vector<int> >]’
prog.cpp:23:45:   required from here
/usr/include/c++/6/bits/move.h:179:5: error: no type named ‘type’ in ‘struct std::enable_if<false, void>’
/usr/include/c++/6/bits/stl_algobase.h: In instantiation of ‘void std::iter_swap(_ForwardIterator1, _ForwardIterator2) [with _ForwardIterator1 = __gnu_cxx::__normal_iterator<const int*, std::vector<int> >; _ForwardIterator2 = __gnu_cxx::__normal_iterator<const int*, std::vector<int> >]’:
/usr/include/c++/6/bits/stl_algo.h:84:20:   required from ‘void std::__move_median_to_first(_Iterator, _Iterator, _Iterator, _Iterator, _Compare) [with _Iterator = __gnu_cxx::__normal_iterator<const int*, std::vector<int> >; _Compare = __gnu_cxx::__ops::_Iter_less_iter]’
/usr/include/c++/6/bits/stl_algo.h:1918:34:   required from ‘_RandomAccessIterator std::__unguarded_partition_pivot(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<const int*, std::vector<int> >; _Compare = __gnu_cxx::__ops::_Iter_less_iter]’
/usr/include/c++/6/bits/stl_algo.h:1950:38:   required from ‘void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<const int*, std::vector<int> >; _Size = long int; _Compare = __gnu_cxx::__ops::_Iter_less_iter]’
/usr/include/c++/6/bits/stl_algo.h:1965:25:   required from ‘void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<const int*, std::vector<int> >; _Compare = __gnu_cxx::__ops::_Iter_less_iter]’
/usr/include/c++/6/bits/stl_algo.h:4707:18:   required from ‘void std::sort(_RAIter, _RAIter) [with _RAIter = __gnu_cxx::__normal_iterator<const int*, std::vector<int> >]’
prog.cpp:23:45:   required from here
/usr/include/c++/6/bits/move.h:202:5: note: candidate: template<class _Tp, long unsigned int _Nm> typename std::enable_if<std::__is_swappable<_Tp>::value>::type std::swap(_Tp (&)[_Nm], _Tp (&)[_Nm])
     swap(_Tp (&__a)[_Nm], _Tp (&__b)[_Nm])
     ^~~~
/usr/include/c++/6/bits/move.h:202:5: note:   template argument deduction/substitution failed:
In file included from /usr/include/c++/6/bits/char_traits.h:39:0,
                 from /usr/include/c++/6/ios:40,
                 from /usr/include/c++/6/ostream:38,
                 from /usr/include/c++/6/iostream:39,
                 from prog.cpp:1:
/usr/include/c++/6/bits/stl_algobase.h:148:11: note:   mismatched types ‘_Tp [_Nm]’ and ‘const int’
       swap(*__a, *__b);
       ~~~~^~~~~~~~~~~~
In file included from /usr/include/c++/6/bits/stl_algobase.h:64:0,
                 from /usr/include/c++/6/bits/char_traits.h:39,
                 from /usr/include/c++/6/ios:40,
                 from /usr/include/c++/6/ostream:38,
                 from /usr/include/c++/6/iostream:39,
                 from prog.cpp:1:
/usr/include/c++/6/bits/stl_pair.h:471:5: note: candidate: template<class _T1, class _T2> void std::swap(std::pair<_T1, _T2>&, std::pair<_T1, _T2>&)
     swap(pair<_T1, _T2>& __x, pair<_T1, _T2>& __y)
     ^~~~
/usr/include/c++/6/bits/stl_pair.h:471:5: note:   template argument deduction/substitution failed:
In file included from /usr/include/c++/6/bits/char_traits.h:39:0,
                 from /usr/include/c++/6/ios:40,
                 from /usr/include/c++/6/ostream:38,
                 from /usr/include/c++/6/iostream:39,
                 from prog.cpp:1:
/usr/include/c++/6/bits/stl_algobase.h:148:11: note:   mismatched types ‘std::pair<_T1, _T2>’ and ‘const int’
       swap(*__a, *__b);
       ~~~~^~~~~~~~~~~~
In file included from /usr/include/c++/6/bits/stl_algo.h:61:0,
                 from /usr/include/c++/6/algorithm:62,
                 from prog.cpp:5:
/usr/include/c++/6/bits/stl_heap.h: In instantiation of ‘void std::__adjust_heap(_RandomAccessIterator, _Distance, _Distance, _Tp, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<const int*, std::vector<int> >; _Distance = long int; _Tp = int; _Compare = __gnu_cxx::__ops::_Iter_less_iter]’:
/usr/include/c++/6/bits/stl_heap.h:335:22:   required from ‘void std::__make_heap(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<const int*, std::vector<int> >; _Compare = __gnu_cxx::__ops::_Iter_less_iter]’
/usr/include/c++/6/bits/stl_algo.h:1669:23:   required from ‘void std::__heap_select(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<const int*, std::vector<int> >; _Compare = __gnu_cxx::__ops::_Iter_less_iter]’
/usr/include/c++/6/bits/stl_algo.h:1930:25:   required from ‘void std::__partial_sort(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<const int*, std::vector<int> >; _Compare = __gnu_cxx::__ops::_Iter_less_iter]’
/usr/include/c++/6/bits/stl_algo.h:1945:27:   required from ‘void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<const int*, std::vector<int> >; _Size = long int; _Compare = __gnu_cxx::__ops::_Iter_less_iter]’
/usr/include/c++/6/bits/stl_algo.h:1965:25:   required from ‘void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<const int*, std::vector<int> >; _Compare = __gnu_cxx::__ops::_Iter_less_iter]’
/usr/include/c++/6/bits/stl_algo.h:4707:18:   required from ‘void std::sort(_RAIter, _RAIter) [with _RAIter = __gnu_cxx::__normal_iterator<const int*, std::vector<int> >]’
prog.cpp:23:45:   required from here
/usr/include/c++/6/bits/stl_heap.h:220:29: error: assignment of read-only location ‘__first.__gnu_cxx::__normal_iterator<_Iterator, _Container>::operator+<const int*, std::vector<int> >(__holeIndex).__gnu_cxx::__normal_iterator<_Iterator, _Container>::operator*<const int*, std::vector<int> >()’
    *(__first + __holeIndex) = _GLIBCXX_MOVE(*(__first + __secondChild));
                             ^
/usr/include/c++/6/bits/stl_heap.h:226:29: error: assignment of read-only location ‘__first.__gnu_cxx::__normal_iterator<_Iterator, _Container>::operator+<const int*, std::vector<int> >(__holeIndex).__gnu_cxx::__normal_iterator<_Iterator, _Container>::operator*<const int*, std::vector<int> >()’
    *(__first + __holeIndex) = _GLIBCXX_MOVE(*(__first
                             ^
In file included from /usr/include/c++/6/bits/char_traits.h:39:0,
                 from /usr/include/c++/6/ios:40,
                 from /usr/include/c++/6/ostream:38,
                 from /usr/include/c++/6/iostream:39,
                 from prog.cpp:1:
/usr/include/c++/6/bits/stl_algobase.h: In instantiation of ‘_BI2 std::__copy_move_backward_a(_BI1, _BI1, _BI2) [with bool _IsMove = true; _BI1 = const int*; _BI2 = const int*]’:
/usr/include/c++/6/bits/stl_algobase.h:598:5:   required from ‘_BI2 std::__copy_move_backward_a2(_BI1, _BI1, _BI2) [with bool _IsMove = true; _BI1 = __gnu_cxx::__normal_iterator<const int*, std::vector<int> >; _BI2 = __gnu_cxx::__normal_iterator<const int*, std::vector<int> >]’
/usr/include/c++/6/bits/stl_algobase.h:668:48:   required from ‘_BI2 std::move_backward(_BI1, _BI1, _BI2) [with _BI1 = __gnu_cxx::__normal_iterator<const int*, std::vector<int> >; _BI2 = __gnu_cxx::__normal_iterator<const int*, std::vector<int> >]’
/usr/include/c++/6/bits/stl_algo.h:1848:8:   required from ‘void std::__insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<const int*, std::vector<int> >; _Compare = __gnu_cxx::__ops::_Iter_less_iter]’
/usr/include/c++/6/bits/stl_algo.h:1882:25:   required from ‘void std::__final_insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<const int*, std::vector<int> >; _Compare = __gnu_cxx::__ops::_Iter_less_iter]’
/usr/include/c++/6/bits/stl_algo.h:1968:31:   required from ‘void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<const int*, std::vector<int> >; _Compare = __gnu_cxx::__ops::_Iter_less_iter]’
/usr/include/c++/6/bits/stl_algo.h:4707:18:   required from ‘void std::sort(_RAIter, _RAIter) [with _RAIter = __gnu_cxx::__normal_iterator<const int*, std::vector<int> >]’
prog.cpp:23:45:   required from here
/usr/include/c++/6/bits/stl_algobase.h:588:58: error: no matching function for call to ‘std::__copy_move_backward<true, true, std::random_access_iterator_tag>::__copy_move_b(const int*&, const int*&, const int*&)’
       return std::__copy_move_backward<_IsMove, __simple,
              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
                                 _Category>::__copy_move_b(__first,
                                 ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
          __last,
          ~~~~~~~                                          
          __result);
          ~~~~~~~~~                                        
/usr/include/c++/6/bits/stl_algobase.h:559:9: note: candidate: template<class _Tp> static _Tp* std::__copy_move_backward<_IsMove, true, std::random_access_iterator_tag>::__copy_move_b(const _Tp*, const _Tp*, _Tp*) [with _Tp = _Tp; bool _IsMove = true]
         __copy_move_b(const _Tp* __first, const _Tp* __last, _Tp* __result)
         ^~~~~~~~~~~~~
/usr/include/c++/6/bits/stl_algobase.h:559:9: note:   template argument deduction/substitution failed:
/usr/include/c++/6/bits/stl_algobase.h:588:58: note:   deduced conflicting types for parameter ‘_Tp’ (‘int’ and ‘const int’)
       return std::__copy_move_backward<_IsMove, __simple,
              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
                                 _Category>::__copy_move_b(__first,
                                 ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
          __last,
          ~~~~~~~                                          
          __result);
          ~~~~~~~~~                                        
stdout

Standard output is empty