Submission #707377

#TimeUsernameProblemLanguageResultExecution timeMemory
707377EthanKim8683Bitaro’s Party (JOI18_bitaro)C++17
7 / 100
1701 ms524288 KiB
#include<bits/stdc++.h> using namespace std; using I=int; const I N=100000; const I Q=100000; const I MIN=-1e9; vector<I>adjs[N]; set<I>bsys[Q]; vector<I>inds[N]; set<pair<I,I>>tops[N]; I ress[Q]; I dp[N]; I main(){ cin.tie(0)->sync_with_stdio(0); I n,m,q;cin>>n>>m>>q; for(I i=0;i<m;i++){ I s,e;cin>>s>>e,s--,e--; adjs[s].push_back(e); } fill_n(ress,q,MIN); for(I i=0;i<q;i++){ I t,y;cin>>t>>y,t--; inds[t].push_back(i); for(I j=0;j<y;j++){ I c;cin>>c,c--; bsys[i].insert(c); } } I siz=sqrt(n); for(I i=0;i<n;i++)tops[i].insert({0,i}); for(I i=0;i<n;i++){ for(auto j:inds[i]){ for(auto[dis,k]:tops[i])if(!bsys[j].count(k)){ress[j]=-dis;break;} if(ress[j]!=MIN)continue; if(bsys[j].size()<=siz)continue; fill_n(dp,i+1,0); for(auto c:bsys[j])dp[c]=MIN; for(I k=0;k<i;k++)if(dp[k]!=MIN)for(auto l:adjs[k])if(l<=i)dp[l]=max(dp[l],dp[k]+1); ress[j]=dp[i]; } for(auto j:adjs[i])for(auto[dis,k]:tops[i]){ tops[j].insert({dis-1,k}); while(tops[j].size()>siz)tops[j].erase(prev(tops[j].end())); } } for(I i=0;i<q;i++)printf("%i\n",ress[i]==MIN?-1:ress[i]); }

Compilation message (stderr)

bitaro.cpp: In function 'I main()':
bitaro.cpp:35:24: warning: comparison of integer expressions of different signedness: 'std::set<int>::size_type' {aka 'long unsigned int'} and 'I' {aka 'int'} [-Wsign-compare]
   35 |       if(bsys[j].size()<=siz)continue;
      |          ~~~~~~~~~~~~~~^~~~~
bitaro.cpp:43:27: warning: comparison of integer expressions of different signedness: 'std::set<std::pair<int, int> >::size_type' {aka 'long unsigned int'} and 'I' {aka 'int'} [-Wsign-compare]
   43 |       while(tops[j].size()>siz)tops[j].erase(prev(tops[j].end()));
      |             ~~~~~~~~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...