Submission #68650

#TimeUsernameProblemLanguageResultExecution timeMemory
68650TadijaSebezBitaro’s Party (JOI18_bitaro)C++11
0 / 100
12 ms9720 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define mp make_pair #define pb push_back const int N=100050; const int inf=1e9+7; const int S=100; vector<int> E[N]; vector<pair<int,int> > dp[N]; set<pair<int,int> > pq; map<int,int> dist[N]; bool was[N]; int tmp[N]; int main() { int n,m,q,i,j,u,v,k; scanf("%i %i %i",&n,&m,&q); for(i=1;i<=m;i++) scanf("%i %i",&u,&v),E[v].pb(u); for(i=1;i<=m;i++) { pq.insert(mp(0,i)); for(j=0;j<E[i].size();j++) { v=E[i][j]; for(k=0;k<dp[v].size();k++) { int h=dp[v][k].second; if(dist[i].count(h) && pq.count(mp(dist[i][h],h))) { if(dist[i][h]<dp[v][k].first+1) { pq.erase(mp(dist[i][h],h)); dist[i][h]=dp[v][k].first+1; pq.insert(mp(dist[i][h],h)); } } else pq.insert(mp(dp[v][k].first+1,dp[v][k].second)),dist[i][h]=dp[v][k].first+1; if(pq.size()>=S) pq.erase(pq.begin()); } } while(pq.size()) dp[i].pb(*pq.begin()),pq.erase(pq.begin()); } while(q--) { int sz,st; vector<int> x; scanf("%i %i",&st,&sz); x.resize(sz); for(i=0;i<sz;i++) scanf("%i",&x[i]),was[x[i]]=1; if(sz>=S) { for(i=1;i<=st;i++) { if(was[i]) tmp[i]=-inf; else tmp[i]=0; for(j=0;j<E[i].size();j++) tmp[i]=max(tmp[i],tmp[E[i][j]]+1); } if(tmp[st]>=0) printf("%i\n",tmp[st]); else printf("-1\n"); } else { int ans=-1; for(i=0;i<dp[st].size();i++) if(!was[dp[st][i].second]) ans=dp[st][i].first; printf("%i\n",ans); } for(i=0;i<sz;i++) was[x[i]]=0; } return 0; }

Compilation message (stderr)

bitaro.cpp: In function 'int main()':
bitaro.cpp:23:12: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(j=0;j<E[i].size();j++)
           ~^~~~~~~~~~~~
bitaro.cpp:26:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for(k=0;k<dp[v].size();k++)
            ~^~~~~~~~~~~~~
bitaro.cpp:57:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(j=0;j<E[i].size();j++) tmp[i]=max(tmp[i],tmp[E[i][j]]+1);
             ~^~~~~~~~~~~~
bitaro.cpp:65:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for(i=0;i<dp[st].size();i++) if(!was[dp[st][i].second]) ans=dp[st][i].first;
            ~^~~~~~~~~~~~~~
bitaro.cpp:18:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%i %i %i",&n,&m,&q);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~
bitaro.cpp:19:40: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(i=1;i<=m;i++) scanf("%i %i",&u,&v),E[v].pb(u);
                    ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~
bitaro.cpp:48:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%i %i",&st,&sz);
   ~~~~~^~~~~~~~~~~~~~~~~
bitaro.cpp:50:38: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   for(i=0;i<sz;i++) scanf("%i",&x[i]),was[x[i]]=1;
                     ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...