Submission #834759

#TimeUsernameProblemLanguageResultExecution timeMemory
834759IS_RushdiKeys (IOI21_keys)C++17
20 / 100
3093 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]); } vector<vector<vector<int>>>zoro_is_gay=a; 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){ while(a[node][key].size() > 0){ q.push(a[node][key].back()); a[node][key].pop_back(); } } } 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; a=zoro_is_gay; } 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...