제출 #95079

#제출 시각아이디문제언어결과실행 시간메모리
95079Mahdi_JfriBitaro’s Party (JOI18_bitaro)C++14
0 / 100
16 ms8824 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back typedef vector<pair<int,int>> vii; const int maxn = 1e5 + 20; const int sq = 320; vector<int> in[maxn]; vii path[maxn]; int dp[maxn] , mx[maxn] , all[maxn]; bool is[maxn]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n , m , q; cin >> n >> m >> q; for(int i = 0; i < m; i++) { int a , b; cin >> a >> b; a-- , b--; in[b].pb(a); } memset(mx , -1 , sizeof mx); for(int v = 0; v < n; v++) { int t = 0; all[t++] = v , mx[v] = 0; for(auto u : in[v]) for(auto w : path[u]) { mx[w.second] = max(mx[w.second] , w.first + 1); all[t++] = w.second; } for(int i = 0; i < t; i++) if(mx[all[i]] != -1) path[v].pb({mx[all[i]] , all[i]}) , mx[all[i]] = -1; sort(path[v].begin() , path[v].end()); reverse(path[v].begin() , path[v].end()); while(path[v].size() > sq) path[v].pop_back(); } while(q--) { int v , sz; cin >> v >> sz; v--; vector<int> tmp; while(sz--) { int x; cin >> x; x--; tmp.pb(x); is[x] = 1; } int ans; if(sz > sq) { for(int i = 0; i <= v; i++) { dp[i] = -1e9; if(!is[i]) dp[i] = 0; for(auto u : in[i]) dp[i] = max(dp[i] , dp[u] + 1); } dp[v] = max(dp[v] , -1); cout << dp[v] << endl; } else { int res; bool f = 0; for(auto x : path[v]) if(!is[x.second]) { cout << x.first << endl; f = 1; break; } if(!f) cout << -1 << endl; } for(auto x : tmp) is[x] = 0; } }

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

bitaro.cpp: In function 'int main()':
bitaro.cpp:89:8: warning: unused variable 'res' [-Wunused-variable]
    int res;
        ^~~
bitaro.cpp:72:7: warning: unused variable 'ans' [-Wunused-variable]
   int ans;
       ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...