Submission #805608

#TimeUsernameProblemLanguageResultExecution timeMemory
805608raysh07열쇠 (IOI21_keys)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;
#define INF (int)1e9

int n, m;
const int N = 3e5 + 69;
vector <pair<int, int>> adj[N], pend[N];
bool have[N], vis[N]; //do i have this colour? 
int cnt[N];

vector<int> find_reachable(vector<int> r, vector<int> u, vector<int> v, vector<int> c) {
    n = r.size();
    m = u.size();
    
    for (int i = 0; i < m; i++){
        adj[u[i]].push_back({v[i], c[i]});
        adj[v[i]].push_back({u[i], c[i]});
    }
    
    int mn = INF;
    
    for (int i = 0; i < n; i++){
        for (int j = 0; j < n; j++){
            have[j] = false;
            pend[j].clear();
        }
        
        queue <int> q;
        q.push(i);
        
        while (!q.empty()){
            cnt[i]++;
            int u = q.front();
            q.pop();
            
            have[r[u]] = true;
            for (auto x : pend[r[u]]){
                vis[x] = true;
                q.push(x);
            }
            pend[r[u]].clear();
            
            for (auto [v, c] : adj[u]){
                if (vis[v]) continue;
                if (have[c]){
                    vis[v] = true;
                    q.push(v);
                } else {
                    pend[c].push_back(v);
                }
            }
        }
        
        mn = min(mn, cnt[i]);
    }
    
    vector <int> ans;
    for (int i = 0; i < n; i++){
        if (mn == cnt[i]) ans.push_back(i);
    }
    
    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:38:20: error: no match for 'operator[]' (operand types are 'bool [300069]' and 'std::pair<int, int>')
   38 |                 vis[x] = true;
      |                    ^
keys.cpp:39:25: error: no matching function for call to 'std::queue<int>::push(std::pair<int, int>&)'
   39 |                 q.push(x);
      |                         ^
In file included from /usr/include/c++/10/queue:64,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from keys.cpp:1:
/usr/include/c++/10/bits/stl_queue.h:265:7: note: candidate: 'void std::queue<_Tp, _Sequence>::push(const value_type&) [with _Tp = int; _Sequence = std::deque<int, std::allocator<int> >; std::queue<_Tp, _Sequence>::value_type = int]'
  265 |       push(const value_type& __x)
      |       ^~~~
/usr/include/c++/10/bits/stl_queue.h:265:30: note:   no known conversion for argument 1 from 'std::pair<int, int>' to 'const value_type&' {aka 'const int&'}
  265 |       push(const value_type& __x)
      |            ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_queue.h:270:7: note: candidate: 'void std::queue<_Tp, _Sequence>::push(std::queue<_Tp, _Sequence>::value_type&&) [with _Tp = int; _Sequence = std::deque<int, std::allocator<int> >; std::queue<_Tp, _Sequence>::value_type = int]'
  270 |       push(value_type&& __x)
      |       ^~~~
/usr/include/c++/10/bits/stl_queue.h:270:25: note:   no known conversion for argument 1 from 'std::pair<int, int>' to 'std::queue<int>::value_type&&' {aka 'int&&'}
  270 |       push(value_type&& __x)
      |            ~~~~~~~~~~~~~^~~
keys.cpp:49:40: error: no matching function for call to 'std::vector<std::pair<int, int> >::push_back(std::tuple_element<0, std::pair<int, int> >::type&)'
   49 |                     pend[c].push_back(v);
      |                                        ^
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/functional:62,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 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 = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::value_type = std::pair<int, 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 'std::tuple_element<0, std::pair<int, int> >::type' {aka 'int'} to 'const value_type&' {aka 'const std::pair<int, 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 = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::value_type = std::pair<int, 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 'std::tuple_element<0, std::pair<int, int> >::type' {aka 'int'} to 'std::vector<std::pair<int, int> >::value_type&&' {aka 'std::pair<int, int>&&'}
 1203 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~