Submission #1009384

#TimeUsernameProblemLanguageResultExecution timeMemory
1009384LilPlutonEaster Eggs (info1cup17_eastereggs)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 5; vector<vector<int>>g(N); vector<int>v; void dfs(int node,int par) { v.push_back(node); for(int i : g[node]) if(i != par) dfs(i, node); } int findEgg(int N, vector<pair<int,int>> bridges) { g.clear(); g.resize(N + 1); v.clear(); for(auto i : bridges) { g[i.first].push_back(g[i].second); g[i.second].push_back(g[i].first); } dfs(1,1); int l = 0, r = v.size() - 1; while(l < r) { int mid = (l + r) / 2; vector<int>w; for(int i = l; i <= mid; ++i) { w.push_back(i); } if(query(w)) r = mid; else l = mid + 1; } return l; }

Compilation message (stderr)

eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:24:31: error: no match for 'operator[]' (operand types are 'std::vector<std::vector<int> >' and 'std::pair<int, int>')
   24 |         g[i.first].push_back(g[i].second);
      |                               ^
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from eastereggs.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:1043:7: note: candidate: 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >; std::vector<_Tp, _Alloc>::reference = std::vector<int>&; std::vector<_Tp, _Alloc>::size_type = long unsigned int]'
 1043 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1043:28: note:   no known conversion for argument 1 from 'std::pair<int, int>' to 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'}
 1043 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |                  ~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:1061:7: note: candidate: 'std::vector<_Tp, _Alloc>::const_reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) const [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >; std::vector<_Tp, _Alloc>::const_reference = const std::vector<int>&; std::vector<_Tp, _Alloc>::size_type = long unsigned int]'
 1061 |       operator[](size_type __n) const _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1061:28: note:   no known conversion for argument 1 from 'std::pair<int, int>' to 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'}
 1061 |       operator[](size_type __n) const _GLIBCXX_NOEXCEPT
      |                  ~~~~~~~~~~^~~
eastereggs.cpp:25:32: error: no match for 'operator[]' (operand types are 'std::vector<std::vector<int> >' and 'std::pair<int, int>')
   25 |         g[i.second].push_back(g[i].first);
      |                                ^
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from eastereggs.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:1043:7: note: candidate: 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >; std::vector<_Tp, _Alloc>::reference = std::vector<int>&; std::vector<_Tp, _Alloc>::size_type = long unsigned int]'
 1043 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1043:28: note:   no known conversion for argument 1 from 'std::pair<int, int>' to 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'}
 1043 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |                  ~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:1061:7: note: candidate: 'std::vector<_Tp, _Alloc>::const_reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) const [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >; std::vector<_Tp, _Alloc>::const_reference = const std::vector<int>&; std::vector<_Tp, _Alloc>::size_type = long unsigned int]'
 1061 |       operator[](size_type __n) const _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1061:28: note:   no known conversion for argument 1 from 'std::pair<int, int>' to 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'}
 1061 |       operator[](size_type __n) const _GLIBCXX_NOEXCEPT
      |                  ~~~~~~~~~~^~~
eastereggs.cpp:39:12: error: 'query' was not declared in this scope
   39 |         if(query(w))
      |            ^~~~~