Submission #834754

#TimeUsernameProblemLanguageResultExecution timeMemory
834754IS_RushdiKeys (IOI21_keys)C++17
20 / 100
3012 ms2097152 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(n,vector<vector<int>>(n,vector<int>())); int mn = 1e9; vector<int>tmp(n,0); 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] = keys.size(); for(int key : keys){ for(int to : a[node][key]){ q.push(to); } } } for(int j = 0; j < n; j++){ // cout << vis[j] << ' '; if(vis[j] != -1) tmp[i]++; } mn = min(mn,tmp[i]); // cout << tmp[i] << endl; } for(int i = 0; i < n; i++){ if(tmp[i] == mn) ans[i] = 1; else ans[i] = 0; } return ans; } // int main(){ // int n; cin >> n; // vector<int>a(n); // for(int i = 0; i < n; i++) cin >> a[i]; // int m; cin >> m; // vector<int>b(m),c(m),d(m); // for(int i = 0; i < m; i++) cin >> b[i]; // for(int i = 0; i < m; i++) cin >> c[i]; // for(int i = 0; i < m; i++) cin >> d[i]; // vector<int>ans = find_reachable(a,b,c,d); // for(int i = 0; i < n; i++) cout << ans[i] << ' '; // }

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:26: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]
   26 |             if(vis[node] == keys.size()) continue;
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...