Submission #848267

#TimeUsernameProblemLanguageResultExecution timeMemory
848267grossly_overconfidentKeys (IOI21_keys)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; vector<int> find_reachable(vector<int> r, vector<int> u, vector<int> v, vector<int> c){ int n = r.size(); int m = u.size(); vector<vector<int>> adj(n); map<pair<int, int>, int> lock; for (int i = 0; i < m; ++i){ adj[u[i]].push_back(v[i]); adj[v[i]].push_back(u[i]); lock{u[i], v[i]} = c[i]; lock{v[i], u[i]} = c[i]; } vector<int> out(n); for (int i = 0; i < n; ++i){ vector<bool>(n, false) visited; int count = 0; set<int> obtained = {-1}; deque<pair<int, int>> dq; dq.push_back({0, -1}); while (!dq.empty()){ auto h = dq.front(); dq.pop_front(); if (visited[h.first]){ continue; } if (obtained.find(h.second) == obtained.end()){ continue; } visited[h.first] = true; obtained.insert(r[h.first]); count += 1; for (auto k : adj[h.first]){ if (obtained.find(lock[h.first][k]) != obtained.end()){ dq.push_front({k, lock[h.first][k]}); } else{ dq.push_back({k, lock[h.first][k]}); } } } out[i] = count; } int worst = out[0]; for (int i = 0; i < n; ++i){ worst = min(worst, out[i]); } for (int i = 0; i < n; ++i){ out[i] = out[i] == worst; } return out; }

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:12:13: error: expected ';' before '{' token
   12 |         lock{u[i], v[i]} = c[i];
      |             ^
      |             ;
keys.cpp:12:9: warning: statement has no effect [-Wunused-value]
   12 |         lock{u[i], v[i]} = c[i];
      |         ^~~~
keys.cpp:12:26: error: expected primary-expression before '=' token
   12 |         lock{u[i], v[i]} = c[i];
      |                          ^
keys.cpp:13:13: error: expected ';' before '{' token
   13 |         lock{v[i], u[i]} = c[i];
      |             ^
      |             ;
keys.cpp:13:9: warning: statement has no effect [-Wunused-value]
   13 |         lock{v[i], u[i]} = c[i];
      |         ^~~~
keys.cpp:13:26: error: expected primary-expression before '=' token
   13 |         lock{v[i], u[i]} = c[i];
      |                          ^
keys.cpp:17:31: error: expected ';' before 'visited'
   17 |         vector<bool>(n, false) visited;
      |                               ^~~~~~~~
      |                               ;
keys.cpp:25:17: error: 'visited' was not declared in this scope
   25 |             if (visited[h.first]){
      |                 ^~~~~~~
keys.cpp:31:13: error: 'visited' was not declared in this scope
   31 |             visited[h.first] = true;
      |             ^~~~~~~
keys.cpp:35:39: error: no match for 'operator[]' (operand types are 'std::map<std::pair<int, int>, int>' and 'int')
   35 |                 if (obtained.find(lock[h.first][k]) != obtained.end()){
      |                                       ^
In file included from /usr/include/c++/10/map:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:81,
                 from keys.cpp:1:
/usr/include/c++/10/bits/stl_map.h:492:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](const key_type&) [with _Key = std::pair<int, int>; _Tp = int; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >; std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type = int; std::map<_Key, _Tp, _Compare, _Alloc>::key_type = std::pair<int, int>]'
  492 |       operator[](const key_type& __k)
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_map.h:492:34: note:   no known conversion for argument 1 from 'int' to 'const key_type&' {aka 'const std::pair<int, int>&'}
  492 |       operator[](const key_type& __k)
      |                  ~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_map.h:512:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](std::map<_Key, _Tp, _Compare, _Alloc>::key_type&&) [with _Key = std::pair<int, int>; _Tp = int; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >; std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type = int; std::map<_Key, _Tp, _Compare, _Alloc>::key_type = std::pair<int, int>]'
  512 |       operator[](key_type&& __k)
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_map.h:512:29: note:   no known conversion for argument 1 from 'int' to 'std::map<std::pair<int, int>, int>::key_type&&' {aka 'std::pair<int, int>&&'}
  512 |       operator[](key_type&& __k)
      |                  ~~~~~~~~~~~^~~
keys.cpp:36:43: error: no match for 'operator[]' (operand types are 'std::map<std::pair<int, int>, int>' and 'int')
   36 |                     dq.push_front({k, lock[h.first][k]});
      |                                           ^
In file included from /usr/include/c++/10/map:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:81,
                 from keys.cpp:1:
/usr/include/c++/10/bits/stl_map.h:492:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](const key_type&) [with _Key = std::pair<int, int>; _Tp = int; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >; std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type = int; std::map<_Key, _Tp, _Compare, _Alloc>::key_type = std::pair<int, int>]'
  492 |       operator[](const key_type& __k)
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_map.h:492:34: note:   no known conversion for argument 1 from 'int' to 'const key_type&' {aka 'const std::pair<int, int>&'}
  492 |       operator[](const key_type& __k)
      |                  ~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_map.h:512:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](std::map<_Key, _Tp, _Compare, _Alloc>::key_type&&) [with _Key = std::pair<int, int>; _Tp = int; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >; std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type = int; std::map<_Key, _Tp, _Compare, _Alloc>::key_type = std::pair<int, int>]'
  512 |       operator[](key_type&& __k)
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_map.h:512:29: note:   no known conversion for argument 1 from 'int' to 'std::map<std::pair<int, int>, int>::key_type&&' {aka 'std::pair<int, int>&&'}
  512 |       operator[](key_type&& __k)
      |                  ~~~~~~~~~~~^~~
keys.cpp:36:56: error: no matching function for call to 'std::deque<std::pair<int, int> >::push_front(<brace-enclosed initializer list>)'
   36 |                     dq.push_front({k, lock[h.first][k]});
      |                                                        ^
In file included from /usr/include/c++/10/deque:67,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:68,
                 from keys.cpp:1:
/usr/include/c++/10/bits/stl_deque.h:1456:7: note: candidate: 'void std::deque<_Tp, _Alloc>::push_front(const value_type&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::deque<_Tp, _Alloc>::value_type = std::pair<int, int>]'
 1456 |       push_front(const value_type& __x)
      |       ^~~~~~~~~~
/usr/include/c++/10/bits/stl_deque.h:1456:36: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const std::pair<int, int>&'}
 1456 |       push_front(const value_type& __x)
      |                  ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_deque.h:1471:7: note: candidate: 'void std::deque<_Tp, _Alloc>::push_front(std::deque<_Tp, _Alloc>::value_type&&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::deque<_Tp, _Alloc>::value_type = std::pair<int, int>]'
 1471 |       push_front(value_type&& __x)
      |       ^~~~~~~~~~
/usr/include/c++/10/bits/stl_deque.h:1471:31: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::deque<std::pair<int, int> >::value_type&&' {aka 'std::pair<int, int>&&'}
 1471 |       push_front(value_type&& __x)
      |                  ~~~~~~~~~~~~~^~~
keys.cpp:39:42: error: no match for 'operator[]' (operand types are 'std::map<std::pair<int, int>, int>' and 'int')
   39 |                     dq.push_back({k, lock[h.first][k]});
      |                                          ^
In file included from /usr/include/c++/10/map:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:81,
                 from keys.cpp:1:
/usr/include/c++/10/bits/stl_map.h:492:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](const key_type&) [with _Key = std::pair<int, int>; _Tp = int; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >; std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type = int; std::map<_Key, _Tp, _Compare, _Alloc>::key_type = std::pair<int, int>]'
  492 |       operator[](const key_type& __k)
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_map.h:492:34: note:   no known conversion for argument 1 from 'int' to 'const key_type&' {aka 'const std::pair<int, int>&'}
  492 |       operator[](const key_type& __k)
      |                  ~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_map.h:512:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](std::map<_Key, _Tp, _Compare, _Alloc>::key_type&&) [with _Key = std::pair<int, int>; _Tp = int; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >; std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type = int; std::map<_Key, _Tp, _Compare, _Alloc>::key_type = std::pair<int, int>]'
  512 |       operator[](key_type&& __k)
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_map.h:512:29: note:   no known conversion for argument 1 from 'int' to 'std::map<std::pair<int, int>, int>::key_type&&' {aka 'std::pair<int, int>&&'}
  512 |       operator[](key_type&& __k)
      |                  ~~~~~~~~~~~^~~
keys.cpp:39:55: error: no matching function for call to 'std::deque<std::pair<int, int> >::push_back(<brace-enclosed initializer list>)'
   39 |                     dq.push_back({k, lock[h.first][k]});
      |                                                       ^
In file included from /usr/include/c++/10/deque:67,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:68,
                 from keys.cpp:1:
/usr/include/c++/10/bits/stl_deque.h:1493:7: note: candidate: 'void std::deque<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::deque<_Tp, _Alloc>::value_type = std::pair<int, int>]'
 1493 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_deque.h:1493:35: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const std::pair<int, int>&'}
 1493 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_deque.h:1508:7: note: candidate: 'void std::deque<_Tp, _Alloc>::push_back(std::deque<_Tp, _Alloc>::value_type&&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::deque<_Tp, _Alloc>::value_type = std::pair<int, int>]'
 1508 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_deque.h:1508:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::deque<std::pair<int, int> >::value_type&&' {aka 'std::pair<int, int>&&'}
 1508 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~