제출 #707426

#제출 시각아이디문제언어결과실행 시간메모리
707426EthanKim8683Bitaro’s Party (JOI18_bitaro)C++17
7 / 100
2080 ms358260 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>adjs1[N],adjs2[N]; set<I>bsys[Q]; vector<I>inds[N]; set<I>viss; vector<pair<I,I>>pres[N],tops[N]; I ress[Q]; I diss[N]; I tims[N]; I tim=1; I dfs(I a,I i){ if(tims[a]==tim)return diss[a]; tims[a]=tim,diss[a]=bsys[i].count(a)?MIN:0; for(auto b:adjs2[a])if(dfs(b,i)!=MIN)diss[a]=max(diss[a],diss[b]+1); return diss[a]; } 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--; adjs1[s].push_back(e); adjs2[e].push_back(s); } 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)/2; for(I i=0;i<n;i++){ pres[i].push_back({0,i}); sort(pres[i].begin(),pres[i].end()); viss.clear(); for(I j=0;j<pres[i].size()&&tops[i].size()<siz;j++){ auto[dis,k]=pres[i][j]; if(viss.count(k))continue; viss.insert(k),tops[i].push_back({dis,k}); } 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; ress[j]=dfs(i,j),tim++; } for(auto j:adjs1[i])for(auto[dis,k]:tops[i])pres[j].push_back({dis-1,k}); pres[i].clear(),tops[i].clear(); } for(I i=0;i<q;i++)printf("%i\n",ress[i]==MIN?-1:ress[i]); }

컴파일 시 표준 에러 (stderr) 메시지

bitaro.cpp: In function 'I main()':
bitaro.cpp:44:16: warning: comparison of integer expressions of different signedness: 'I' {aka 'int'} and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |     for(I j=0;j<pres[i].size()&&tops[i].size()<siz;j++){
      |               ~^~~~~~~~~~~~~~~
bitaro.cpp:44:47: warning: comparison of integer expressions of different signedness: 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} and 'I' {aka 'int'} [-Wsign-compare]
   44 |     for(I j=0;j<pres[i].size()&&tops[i].size()<siz;j++){
      |                                 ~~~~~~~~~~~~~~^~~~
bitaro.cpp:52:24: warning: comparison of integer expressions of different signedness: 'std::set<int>::size_type' {aka 'long unsigned int'} and 'I' {aka 'int'} [-Wsign-compare]
   52 |       if(bsys[j].size()<siz)continue;
      |          ~~~~~~~~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...