Submission #974560

#TimeUsernameProblemLanguageResultExecution timeMemory
974560onlk97Keys (IOI21_keys)C++17
9 / 100
178 ms61420 KiB
#include <vector> #include <bits/stdc++.h> using namespace std; vector <int> in[300010],out[300010]; bool visited[300010]; stack <int> st; void dfs1(int cur){ visited[cur]=1; for (int i:out[cur]){ if (!visited[i]) dfs1(i); } st.push(cur); } vector <vector <int> > scc; int belong[300010],idx; vector <int> cc; void dfs2(int cur){ cc.push_back(cur); belong[cur]=idx; visited[cur]=1; for (int i:in[cur]){ if (!visited[i]) dfs2(i); } } vector <int> find_reachable(vector <int> r,vector <int> u,vector <int> v,vector <int> c){ int n=r.size(),m=u.size(); for (int i=0; i<m; i++){ if (r[u[i]]==c[i]){ out[u[i]].push_back(v[i]); in[v[i]].push_back(u[i]); } if (r[v[i]]==c[i]){ out[v[i]].push_back(u[i]); in[u[i]].push_back(v[i]); } } for (int i=0; i<n; i++){ if (!visited[i]) dfs1(i); } for (int i=0; i<n; i++) visited[i]=0; while (!st.empty()){ int tp=st.top(); st.pop(); if (visited[tp]) continue; dfs2(tp); scc.push_back(cc); idx++; cc.clear(); } vector <int> safe; for (int i=0; i<n; i++){ int ok=1; for (int j:out[i]){ if (belong[i]!=belong[j]) ok=0; } safe.push_back(ok); } int mn=1e9; for (auto i:scc){ bool ok=1; for (int j:i){ if (!safe[j]) ok=0; } if (ok) mn=min(mn,(int)i.size()); } vector <int> ans(n,0); for (auto i:scc){ bool ok=1; for (int j:i){ if (!safe[j]) ok=0; } if (ok&&i.size()==mn){ for (int j:i) ans[j]=1; } } 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:71:25: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   71 |         if (ok&&i.size()==mn){
      |                 ~~~~~~~~^~~~
#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...