제출 #630095

#제출 시각아이디문제언어결과실행 시간메모리
630095ertoBitaro’s Party (JOI18_bitaro)C++17
0 / 100
13 ms19136 KiB
#include <bits/stdc++.h> typedef long long int ll; #define INF 1000000000000000000 #define INF2 998244353 #define N (ll)(2e5 + 5) using namespace std; #define int ll #define lsb(x) (x & (-x)) int n, m, q, g, h, t1, t2; vector<int> v[N], qu[N]; int dp[N], ans[N]; vector<int> c[N]; int k = 100; int val[N]; vector<pair<int, int>> best [N]; bool used[N]; void solve(){ cin >> n >> m >> q; for(int i=1; i<=m; i++){ cin >> g >> h; v[h].push_back(g); } for(int i=1; i<=q; i++){ cin >> g >> h; for(int j=1; j<=h; j++){ cin >> t1; c[i].push_back(t1); } if(h > k){ for(int j=1; j<=n; j++)dp[i] = 0; for(int j : c[i])dp[i] = -INF; for(int j=1; j<=g; j++){ for(int u : v[j]){ dp[j] = max(dp[j], dp[u] + 1); } } if(dp[g] >= 0)ans[i] = dp[g]; else ans[i] = -1; } else{ qu[g].push_back(i); } } for(int i=1; i<=n; i++){ vector<int> ch; best[i].push_back({0, i}); for(int u : v[i]){ for(auto z : best[u]){ val[z.second] = max(val[z.second], z.first + 1); ch.push_back(z.second); } } for(int j : ch){ if(!used[j]){ best[i].push_back({val[j], j}); used[j] = 1; } } for(int j : ch){ used[j] = 0; val[j] = 0; } sort(best[i].begin(), best[i].end(), greater<pair<int, int>>()); if(best[i].size() > k)best[i].resize(k); for(int j : qu[i]){ for(int cc : c[j]){ used[cc] = 1; } for(auto p : best[i]){ if(!used[p.second]){ ans[j] = p.first; break; } } for(int cc : c[j]){ used[cc] = 0; } } } for(int i=1; i<=q; i++){ cout << ans[i] << '\n'; } } signed main(){ ios_base::sync_with_stdio(0); cin.tie(0); int T = 1; //cin>>T; while (T--){ solve(); } }

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

bitaro.cpp: In function 'void solve()':
bitaro.cpp:34:21: warning: unused variable 'j' [-Wunused-variable]
   34 |             for(int j : c[i])dp[i] = -INF;
      |                     ^
bitaro.cpp:73:27: warning: comparison of integer expressions of different signedness: 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} and 'll' {aka 'long long int'} [-Wsign-compare]
   73 |         if(best[i].size() > k)best[i].resize(k);
      |            ~~~~~~~~~~~~~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...