Submission #991773

#TimeUsernameProblemLanguageResultExecution timeMemory
991773simona1230Bitaro’s Party (JOI18_bitaro)C++17
0 / 100
1 ms3420 KiB
#include <bits/stdc++.h> using namespace std; void speed() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); } int n,m,q; vector<int> v[100001]; void read() { cin>>n>>m>>q; for(int i=1; i<=m; i++) { int x,y; cin>>x>>y; v[x].push_back(y); } } int dp[100001]; int vert,idx,ans; int used[100001]; void dfs(int i) { //cout<<i<<endl; if(i==vert) { if(used[i]!=idx) ans=0; dp[i]=0; return; } for(int j=0; j<v[i].size(); j++) { int nb=v[i][j]; if(vert<nb)continue; if(dp[nb]==-1) dfs(nb); if(dp[nb]!=-1) dp[i]=max(dp[i],dp[nb]+1); } if(used[i]!=idx) ans=max(ans,dp[i]); } void solve() { for(int i=1; i<=q; i++) { for(int j=1; j<=n; j++) dp[j]=-1; idx=i; int k,b; cin>>vert>>k; for(int j=1; j<=k; j++) { cin>>b; used[b]=i; } ans=-1; dfs(1); cout<<ans<<endl; } } int main() { speed(); read(); solve(); return 0; }

Compilation message (stderr)

bitaro.cpp: In function 'void dfs(int)':
bitaro.cpp:41:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |     for(int j=0; j<v[i].size(); j++)
      |                  ~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...