제출 #399352

#제출 시각아이디문제언어결과실행 시간메모리
399352knightron0Bitaro’s Party (JOI18_bitaro)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define pb push_back #define fr first #define sc second #define clr(a, x) memset(a, x, sizeof(a)) #define dbg(x) cout<<"("<<#x<<"): "<<x<<endl; #define printvector(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout<<*it<<" "; cout<<endl; #define all(v) v.begin(), v.end() #define lcm(a, b) (a * b)/__gcd(a, b) // #define int long long int #define printvecpairs(vec) for(auto it: vec) cout<<it.fr<<' '<<it.sc<<endl; #define endl '\n' #define float long double const int MOD = 1e9 + 7; const int MAXN = 1e5 + 5; const int B = 315; vector<int> adj[MAXN], rev[MAXN]; int dist[MAXN]; bool notok[MAXN]; vector<pair<int, int>> f[MAXN]; bool cmp(int x, int y){ return dist[x] > dist[y]; } signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); #ifdef LOCAL freopen("input.txt", "r", stdin); #endif int n, m, q; cin>>n>>m>>q; for(int i= 0;i<m;i++){ int u, v; cin>>u>>v; adj[u].pb(v); rev[v].pb(u); } clr(dist, 0); bool done[n+2]; clr(done, 0); for(int i=1;i<=n;i++){ vector<int> s; s.pb(i); for(int v: rev[i]){ for(auto it: f[v]){ if(!done[it.sc]){ s.pb(it.sc); done[it.sc] = 1; } dist[it.sc] = max(it.fr+1, dist[it.sc]); } } // printvector(s); int ln = min((int)s.size()-1, B); nth_element(s.begin(), s.begin()+ln, s.end(), cmp); // printvector(s); int curr = 0; for(int u: s){ if(curr >= B){ break; } f[i].pb({dist[u], u}); curr++; } for(auto it: s){ dist[it] = 0; done[it] = 0; } } clr(notok, 0); while(q--){ int x, y; cin>>x>>y; vector<int> v; for(int i= 0;i<y;i++){ int t1; cin>>t1; v.pb(t1); notok[t1] =1; } if(y >= B){ int dp[n+2], ans = -1; for(int i=1;i<=n;i++) dp[i] = -INF; dp[x] = 0; for(int i= x;i>=1;i--){ for(int v: adj[i]){ dp[i] = max(dp[v]+1, dp[i]); } if(notok[i]) continue; ans = max(ans, dp[i]); } cout<<ans<<endl; } else { int ans = -1; for(auto &[d, u]: f[x]){ if(notok[u]) continue; ans = d; break; } cout<<ans<<endl; } for(int i: v){ notok[i] = 0; } } return 0; }

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

bitaro.cpp: In function 'int main()':
bitaro.cpp:87:37: error: 'INF' was not declared in this scope
   87 |      for(int i=1;i<=n;i++) dp[i] = -INF;
      |                                     ^~~