Submission #1042509

#TimeUsernameProblemLanguageResultExecution timeMemory
1042509ProtonDecay314Keys (IOI21_keys)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<ll> vll; typedef vector<vll> vvll; typedef vector<int> vi; typedef vector<vi> vvi; typedef pair<int, int> pi; typedef pair<ll, ll> pll; typedef vector<pi> vpi; typedef vector<pll> vpll; typedef vector<vpi> vvpi; typedef vector<vpll> vvpll; typedef vector<bool> vb; #define IOS ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); #define L(varll, mn, mx) for(ll varll = (mn); varll < (mx); varll++) #define LR(varll, mx, mn) for(ll varll = (mx); varll > (mn); varll--) #define LI(vari, mn, mx) for(int vari = (mn); vari < (mx); vari++) #define LIR(vari, mx, mn) for(int vari = (mx); vari > (mn); vari--) #define INPV(varvec) for(auto& varveci : (varvec)) cin >> varveci #define fi first #define se second #define pb push_back #define INF(type) numeric_limits<type>::max() #define NINF(type) numeric_limits<type>::min() #define TCASES int t; cin >> t; while(t--) // class UF { // public: // int n; // int ncomps; // vi par; // vi csize; // UF(int a_n): n(a_n), ncomps(a_n), par(a_n, 0), csize(a_n, 1) { // for(int i = 0; i < n; i++) par[i] = i; // } // int find(int i) { // return (i == par[i] ? i : par[i] = find(par[i])); // } // int conn(int i, int j) { // return find(i) == find(j); // } // void unify(int i, int j) { // int pari = find(i), parj = find(j); // if(pari == parj) return; // if(csize[pari] < csize[parj]) { // par[pari] = parj; // csize[parj] += csize[pari]; // } else { // par[parj] = pari; // csize[pari] += csize[parj]; // } // ncomps--; // } // } vvpi cant_visit; int bfs(int n, int m, int s, const vi& r, const vvpi& adj) { int num = 0; set<int> found_k; set<int> vis(n, false); queue<pi> q; q.push({s, r[s]}); while(!q.empty()) { auto [i, cr] = q.front(); q.pop(); if(vis[i]) continue; vis[i] = true; num++; if(found_k.count(r[i]) == 0) { while(cant_visit[r[i]].size() > 0) { q.push(cant_visit[r[i]].back()); cant_visit[r[i]].pop_back(); } found_k.insert(r[i]); } for(auto [j, c] : adj[i]) { if(vis[j]) continue; if(found_k.count(c) > 0) q.push({j, c}); else cant_visit[c].pb({j, c}); } } for(int k : found_k) { cant_visit[k].clear(); } return num; } vi find_reachable(vi r, vi u, vi v, vi c) { int n = r.size(), m = u.size(); vi ans(n, 1); vvpi adj; for(int i = 0; i < n; i++) { vpi adjr; adj.pb(adjr); } for(int i = 0; i < n; i++) { vpi cant_visitr; cant_visit.pb(cant_visitr); } for(int i = 0; i < m; i++) { adj[u[i]].pb({v[i], c[i]}); adj[v[i]].pb({u[i], c[i]}); } int mn = INF(int); for(int i = 0; i < n; i++) { ans[i] = bfs(n, m, i, r, adj); mn = min(mn, ans[i]); } for(int i = 0; i < n; i++) { ans[i] = (ans[i] == mn ? 1 : 0); } return ans; }

Compilation message (stderr)

keys.cpp: In function 'int bfs(int, int, int, const vi&, const vvpi&)':
keys.cpp:67:26: error: no matching function for call to 'std::set<int>::set(int&, bool)'
   67 |     set<int> vis(n, false);
      |                          ^
In file included from /usr/include/c++/10/set:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:87,
                 from keys.cpp:1:
/usr/include/c++/10/bits/stl_set.h:271:2: note: candidate: 'template<class _InputIterator> std::set<_Key, _Compare, _Alloc>::set(_InputIterator, _InputIterator, const allocator_type&) [with _InputIterator = _InputIterator; _Key = int; _Compare = std::less<int>; _Alloc = std::allocator<int>]'
  271 |  set(_InputIterator __first, _InputIterator __last,
      |  ^~~
/usr/include/c++/10/bits/stl_set.h:271:2: note:   template argument deduction/substitution failed:
keys.cpp:67:26: note:   deduced conflicting types for parameter '_InputIterator' ('int' and 'bool')
   67 |     set<int> vis(n, false);
      |                          ^
In file included from /usr/include/c++/10/set:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:87,
                 from keys.cpp:1:
/usr/include/c++/10/bits/stl_set.h:265:7: note: candidate: 'std::set<_Key, _Compare, _Alloc>::set(std::initializer_list<_Tp>, const allocator_type&) [with _Key = int; _Compare = std::less<int>; _Alloc = std::allocator<int>; std::set<_Key, _Compare, _Alloc>::allocator_type = std::allocator<int>]'
  265 |       set(initializer_list<value_type> __l, const allocator_type& __a)
      |       ^~~
/usr/include/c++/10/bits/stl_set.h:265:40: note:   no known conversion for argument 1 from 'int' to 'std::initializer_list<int>'
  265 |       set(initializer_list<value_type> __l, const allocator_type& __a)
      |           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_set.h:259:7: note: candidate: 'std::set<_Key, _Compare, _Alloc>::set(std::set<_Key, _Compare, _Alloc>&&, const allocator_type&) [with _Key = int; _Compare = std::less<int>; _Alloc = std::allocator<int>; std::set<_Key, _Compare, _Alloc>::allocator_type = std::allocator<int>]'
  259 |       set(set&& __x, const allocator_type& __a)
      |       ^~~
/usr/include/c++/10/bits/stl_set.h:259:17: note:   no known conversion for argument 1 from 'int' to 'std::set<int>&&'
  259 |       set(set&& __x, const allocator_type& __a)
      |           ~~~~~~^~~
/usr/include/c++/10/bits/stl_set.h:255:7: note: candidate: 'std::set<_Key, _Compare, _Alloc>::set(const std::set<_Key, _Compare, _Alloc>&, const allocator_type&) [with _Key = int; _Compare = std::less<int>; _Alloc = std::allocator<int>; std::set<_Key, _Compare, _Alloc>::allocator_type = std::allocator<int>]'
  255 |       set(const set& __x, const allocator_type& __a)
      |       ^~~
/usr/include/c++/10/bits/stl_set.h:255:22: note:   no known conversion for argument 1 from 'int' to 'const std::set<int>&'
  255 |       set(const set& __x, const allocator_type& __a)
      |           ~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_set.h:251:7: note: candidate: 'std::set<_Key, _Compare, _Alloc>::set(const allocator_type&) [with _Key = int; _Compare = std::less<int>; _Alloc = std::allocator<int>; std::set<_Key, _Compare, _Alloc>::allocator_type = std::allocator<int>]'
  251 |       set(const allocator_type& __a)
      |       ^~~
/usr/include/c++/10/bits/stl_set.h:251:7: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/10/bits/stl_set.h:243:7: note: candidate: 'std::set<_Key, _Compare, _Alloc>::set(std::initializer_list<_Tp>, const _Compare&, const allocator_type&) [with _Key = int; _Compare = std::less<int>; _Alloc = std::allocator<int>; std::set<_Key, _Compare, _Alloc>::allocator_type = std::allocator<int>]'
  243 |       set(initializer_list<value_type> __l,
      |       ^~~
/usr/include/c++/10/bits/stl_set.h:243:40: note:   no known conversion for argument 1 from 'int' to 'std::initializer_list<int>'
  243 |       set(initializer_list<value_type> __l,
      |           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_set.h:231:7: note: candidate: 'std::set<_Key, _Compare, _Alloc>::set(std::set<_Key, _Compare, _Alloc>&&) [with _Key = int; _Compare = std::less<int>; _Alloc = std::allocator<int>]'
  231 |       set(set&&) = default;
      |       ^~~
/usr/include/c++/10/bits/stl_set.h:231:7: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/10/bits/stl_set.h:223:7: note: candidate: 'std::set<_Key, _Compare, _Alloc>::set(const std::set<_Key, _Compare, _Alloc>&) [with _Key = int; _Compare = std::less<int>; _Alloc = std::allocator<int>]'
  223 |       set(const set&) = default;
      |       ^~~
/usr/include/c++/10/bits/stl_set.h:223:7: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/10/bits/stl_set.h:208:2: note: candidate: 'template<class _InputIterator> std::set<_Key, _Compare, _Alloc>::set(_InputIterator, _InputIterator, const _Compare&, const allocator_type&) [with _InputIterator = _InputIterator; _Key = int; _Compare = std::less<int>; _Alloc = std::allocator<int>]'
  208 |  set(_InputIterator __first, _InputIterator __last,
      |  ^~~
/usr/include/c++/10/bits/stl_set.h:208:2: note:   template argument deduction/substitution failed:
keys.cpp:67:26: note:   deduced conflicting types for parameter '_InputIterator' ('int' and 'bool')
   67 |     set<int> vis(n, false);
      |                          ^
In file included from /usr/include/c++/10/set:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:87,
                 from keys.cpp:1:
/usr/include/c++/10/bits/stl_set.h:191:2: note: candidate: 'template<class _InputIterator> std::set<_Key, _Compare, _Alloc>::set(_InputIterator, _InputIterator) [with _InputIterator = _InputIterator; _Key = int; _Compare = std::less<int>; _Alloc = std::allocator<int>]'
  191 |  set(_InputIterator __first, _InputIterator __last)
      |  ^~~
/usr/include/c++/10/bits/stl_set.h:191:2: note:   template argument deduction/substitution failed:
keys.cpp:67:26: note:   deduced conflicting types for parameter '_InputIterator' ('int' and 'bool')
   67 |     set<int> vis(n, false);
      |                          ^
In file included from /usr/include/c++/10/set:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:87,
                 from keys.cpp:1:
/usr/include/c++/10/bits/stl_set.h:176:7: note: candidate: 'std::set<_Key, _Compare, _Alloc>::set(const _Compare&, const allocator_type&) [with _Key = int; _Compare = std::less<int>; _Alloc = std::allocator<int>; std::set<_Key, _Compare, _Alloc>::allocator_type = std::allocator<int>]'
  176 |       set(const _Compare& __comp,
      |       ^~~
/usr/include/c++/10/bits/stl_set.h:176:27: note:   no known conversion for argument 1 from 'int' to 'const std::less<int>&'
  176 |       set(const _Compare& __comp,
      |           ~~~~~~~~~~~~~~~~^~~~~~
/usr/include/c++/10/bits/stl_set.h:167:7: note: candidate: 'std::set<_Key, _Compare, _Alloc>::set() [with _Key = int; _Compare = std::less<int>; _Alloc = std::allocator<int>]'
  167 |       set() = default;
      |       ^~~
/usr/include/c++/10/bits/stl_set.h:167:7: note:   candidate expects 0 arguments, 2 provided
keys.cpp:77:15: error: no match for 'operator[]' (operand types are 'std::set<int>' and 'std::tuple_element<0, std::pair<int, int> >::type' {aka 'int'})
   77 |         if(vis[i]) continue;
      |               ^
keys.cpp:78:12: error: no match for 'operator[]' (operand types are 'std::set<int>' and 'std::tuple_element<0, std::pair<int, int> >::type' {aka 'int'})
   78 |         vis[i] = true;
      |            ^
keys.cpp:90:19: error: no match for 'operator[]' (operand types are 'std::set<int>' and 'std::tuple_element<0, std::pair<int, int> >::type' {aka 'int'})
   90 |             if(vis[j]) continue;
      |                   ^