제출 #399376

#제출 시각아이디문제언어결과실행 시간메모리
399376knightron0Bitaro’s Party (JOI18_bitaro)C++14
100 / 100
1711 ms420564 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(), B); nth_element(s.begin(), s.begin()+ln, s.end(), cmp); // printvector(s); // for(int i= 1;i<=n;i++){ // cout<<dist[i]<<' '; // } // cout<<endl; int curr = 0; for(int u: s){ if(curr >= B) break; f[i].pb({dist[u], u}); curr++; } // cout<<i<<endl; // printvecpairs(f[i]); for(auto it: s) dist[it] = 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] = INT_MIN; 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 = max(d, ans); } cout<<ans<<endl; } for(int i: v){ notok[i] = 0; } } return 0; }

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

bitaro.cpp: In function 'int main()':
bitaro.cpp:100:17: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
  100 |       for(auto &[d, u]: f[x]){
      |                 ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...