Submission #834748

#TimeUsernameProblemLanguageResultExecution timeMemory
834748IS_RushdiKeys (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) {
	vector<int> ans(r.size(), 1);
    int n = r.size();
    int m = u.size();
    vector<vector<vector<int>>>a;
    int mn = 1e9;
    vector<int>tmp(n);
    for(int i = 0; i < m; i++){
        a[v[i]][c[i]].push_back(u[i]);
        a[u[i]][c[i]].push_back(v[i]);
    }
    for(int i = 0; i < n; i++){
        vector<int>vis(n,-1);
        queue<int>q;
        set<int>keys;
        q.push(i);
        while(!q.empty()){
            int node = q.front();
            q.pop();
            if(vis[node] == keys.size()) continue;
            keys.insert(r[node]);
            vis[node] = key.size();
            for(int key : keys){
                while(a[node][key].size() > 0){
                    q.push(a[node][key].back());
                    a[node][key].pop_back();
                }
            }
        }
        for(int i = 0; i < n; i++){
            if(vis[i] != -1) tmp[i]++;
        }
        mn = min(mn,tmp[i]);
    }
    for(int i = 0; i < n; i++){
        if(tmp[i] == mn) ans[i] = 1;
        else ans[i] = 0;
    }
	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:25:26: warning: comparison of integer expressions of different signedness: '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} and 'std::set<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |             if(vis[node] == keys.size()) continue;
keys.cpp:27:25: error: 'key' was not declared in this scope; did you mean 'keys'?
   27 |             vis[node] = key.size();
      |                         ^~~
      |                         keys