제출 #448606

#제출 시각아이디문제언어결과실행 시간메모리
448606jamezzzBitaro’s Party (JOI18_bitaro)C++17
100 / 100
1557 ms414296 KiB
#include <bits/stdc++.h> using namespace std; #ifdef DEBUG #define dbg(...) printf(__VA_ARGS__); #else #define dbg(...) #endif #define sf scanf #define pf printf #define fi first #define se second #define pb emplace_back #define sz(x) (int)x.size() #define mnto(x,y) x=min(x,(__typeof__(x))y) #define mxto(x,y) x=max(x,(__typeof__(x))y) #define INF 1023456789 #define all(x) x.begin(), x.end() typedef long long ll; typedef long double ld; typedef pair<int, int> ii; typedef pair<ll, ll> pll; typedef tuple<int, int, int> iii; typedef tuple<int, int, int, int> iiii; typedef vector<int> vi; typedef vector<ii> vii; typedef vector<pll> vll; mt19937 rng(time(0)); #define maxn 100005 #define rt 400 int n,m,q,s,e,t,y,c[maxn],d[maxn]; bool have[maxn]; vi AL[maxn]; vii idk[maxn],tmp; int main(){ sf("%d%d%d",&n,&m,&q); for(int i=0;i<m;++i){ sf("%d%d",&s,&e); AL[e].pb(s); } for(int i=1;i<=n;++i){ idk[i].pb(0,i); for(int j:AL[i]){ tmp.clear();swap(idk[i],tmp); int pi=0,pj=0; while(pi<sz(tmp)||pj<sz(idk[j])){ if(pi<sz(tmp)&&have[tmp[pi].se]){ ++pi;continue; } if(pj<sz(idk[j])&&have[idk[j][pj].se]){ ++pj;continue; } if(pj==sz(idk[j])||(pi<sz(tmp)&&tmp[pi].fi>=idk[j][pj].fi+1)){ have[tmp[pi].se]=1; idk[i].pb(tmp[pi++]); } else{ have[idk[j][pj].se]=1; idk[i].pb(idk[j][pj].fi+1,idk[j][pj].se),++pj; } if(sz(idk[i])==rt)break; } for(ii pr:idk[i])have[pr.se]=0; } } for(int i=0;i<q;++i){ sf("%d%d",&t,&y); for(int j=0;j<y;++j)sf("%d",&c[j]),have[c[j]]=1; int ans=-1; if(y<rt){ for(ii pr:idk[t])if(!have[pr.se])mxto(ans,pr.fi); } else{ for(int i=1;i<=t;++i)d[i]=(have[i]?-INF:0); for(int i=1;i<=t;++i){ for(int j:AL[i])mxto(d[i],d[j]+1); } if(d[t]<0)ans=-1; else ans=d[t]; } pf("%d\n",ans); for(int j=0;j<y;++j)have[c[j]]=0; } }

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

bitaro.cpp: In function 'int main()':
bitaro.cpp:39:4: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   39 |  sf("%d%d%d",&n,&m,&q);
      |    ^
bitaro.cpp:41:5: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   41 |   sf("%d%d",&s,&e);
      |     ^
bitaro.cpp:70:5: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   70 |   sf("%d%d",&t,&y);
      |     ^
bitaro.cpp:71:25: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   71 |   for(int j=0;j<y;++j)sf("%d",&c[j]),have[c[j]]=1;
      |                         ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...