Submission #436762

#TimeUsernameProblemLanguageResultExecution timeMemory
436762David_MKeys (IOI21_keys)C++17
Compilation error
0 ms0 KiB
#include "keys.h" #include <bits/stdc++.h> using namespace std; #define vi vector<int> #define pb push_back const int N=300005; vi V[N]; pair<int, int> ans[N]; vi find_reachable(vi r, vi u, vi v, vi c){ int n=r.size(), m=u.size(); int Ans[n]; for(int j=0; j<m; j++){ int x=u[j], y=v[j], C=c[j]; V[x].pb({y,C}); V[y].pb({x,C}); } for (int i=0; i<n; i++){ bool C[n]; vi vv[n]; C[r[i]]=true; queue<int> q; q.push(i); while(!q.empty()){ans[i].F++; int x=q.top(); q.pop(); for (auto [y,c]:V[x]) if(!C[c])vv[c].pb(y); else q.push(y); if(!C[r[x]]){for (auto k:vv[r[x]])q.push(k); C[r[i]]=true;} } } sort(ans, ans+n); int R=ans[0].F, o=0; while(ans[o].F==R){ Ans[ans[o].S]=1; o++; } return Ans; }

Compilation message (stderr)

keys.cpp: In function 'std::vector<int> find_reachable(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
keys.cpp:17:16: error: no matching function for call to 'std::vector<int>::push_back(<brace-enclosed initializer list>)'
   17 |   V[x].pb({y,C});
      |                ^
In file included from /usr/include/c++/10/vector:67,
                 from keys.h:1,
                 from keys.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:1187: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]'
 1187 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1187:35: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const int&'}
 1187 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:1203: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]'
 1203 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1203:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<int>::value_type&&' {aka 'int&&'}
 1203 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~
keys.cpp:18:16: error: no matching function for call to 'std::vector<int>::push_back(<brace-enclosed initializer list>)'
   18 |   V[y].pb({x,C});
      |                ^
In file included from /usr/include/c++/10/vector:67,
                 from keys.h:1,
                 from keys.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:1187: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]'
 1187 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1187:35: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const int&'}
 1187 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:1203: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]'
 1203 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1203:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<int>::value_type&&' {aka 'int&&'}
 1203 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~
keys.cpp:27:34: error: 'struct std::pair<int, int>' has no member named 'F'
   27 |         while(!q.empty()){ans[i].F++;
      |                                  ^
keys.cpp:28:21: error: 'class std::queue<int>' has no member named 'top'; did you mean 'pop'?
   28 |             int x=q.top();
      |                     ^~~
      |                     pop
keys.cpp:30:23: error: cannot decompose non-array non-class type 'int'
   30 |             for (auto [y,c]:V[x]) if(!C[c])vv[c].pb(y); else q.push(y);
      |                       ^~~~~
keys.cpp:35:15: error: 'struct std::pair<int, int>' has no member named 'F'
   35 |  int R=ans[0].F, o=0;
      |               ^
keys.cpp:36:12: error: 'o' was not declared in this scope
   36 |  while(ans[o].F==R){
      |            ^
keys.cpp:40:9: error: could not convert 'Ans' from 'int [n]' to 'std::vector<int>'
   40 |  return Ans;
      |         ^~~
      |         |
      |         int [n]