Submission #894832

#TimeUsernameProblemLanguageResultExecution timeMemory
894832MuhammadSaramKeys (IOI21_keys)C++17
9 / 100
73 ms16416 KiB
#include <bits/stdc++.h> using namespace std; const int M = 2000; vector<pair<int,int>> nei[M]; bool vis[M]; int bfs(int u,vector<int> r) { vis[u]=true; set<int> se; se.insert(r[u]); queue<int> q; q.push(u); while (!q.empty()) { int x=q.front(); q.pop(); for (auto i:nei[x]) if (!vis[i.first] and se.find(i.second)!=se.end()) { vis[i.first]=true; q.push(i.first); se.insert(r[i.first]); } } int ans=0; for (int i=0;i<r.size();i++) ans+=(vis[i]); return ans; } vector<int> find_reachable(vector<int> r, vector<int> u, vector<int> v, vector<int> c) { int n=r.size(); int m=u.size(); for (int i=0;i<m;i++) { nei[u[i]].push_back({v[i],c[i]}); nei[v[i]].push_back({u[i],c[i]}); } int ans[n]; for (int i=0;i<n;i++) { ans[i]=bfs(i,r); for (int j=0;j<n;j++) vis[j]=false; } vector<int> ans1; for (int i=0;i<n;i++) { ans1.push_back(1); for (int j=0;j<n;j++) if (ans[i]>ans[j]) { ans1[i]=0; break; } } return ans1; }

Compilation message (stderr)

keys.cpp: In function 'int bfs(int, std::vector<int>)':
keys.cpp:30:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |  for (int i=0;i<r.size();i++)
      |               ~^~~~~~~~~
#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...