Submission #169123

#TimeUsernameProblemLanguageResultExecution timeMemory
169123HuyQuang_re_ZeroBitaro’s Party (JOI18_bitaro)C++14
14 / 100
2063 ms13184 KiB
#include <bits/stdc++.h> using namespace std; vector <int> a[100001],topo; int n,m,q,u,v,i,kq,sl,d[100001],f[100001],s; void DFS(int u) { d[u]=1; for(int i=0;i<a[u].size();i++) { int v=a[u][i]; if(d[v]==0) DFS(v); } topo.push_back(u); } int main() { //freopen("bitaro.inp","r",stdin); //freopen("bitaro.out","w",stdout); cin>>n>>m>>q; while(m--) { cin>>u>>v; a[u].push_back(v); } for(i=1;i<=n;i++) if(d[i]==0) DFS(i); while(q--) { cin>>s>>sl; for(i=1;i<=n;i++) d[i]=0; while(sl--) { cin>>u; d[u]=1; } kq=-1; for(i=0;i<topo.size();i++) { u=topo[i]; f[u]=-1; if(u==s) f[u]=0; for(int i=0;i<a[u].size();i++) { v=a[u][i]; if(f[v]>-1) f[u]=max(f[u],f[v]+1); } if(d[u]==0) kq=max(kq,f[u]); } cout<<kq<<'\n'; } }

Compilation message (stderr)

bitaro.cpp: In function 'void DFS(int)':
bitaro.cpp:8:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0;i<a[u].size();i++)
                 ~^~~~~~~~~~~~
bitaro.cpp: In function 'int main()':
bitaro.cpp:33:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(i=0;i<topo.size();i++)
                 ~^~~~~~~~~~~~
bitaro.cpp:38:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for(int i=0;i<a[u].size();i++)
                         ~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...