Submission #1103530

#TimeUsernameProblemLanguageResultExecution timeMemory
1103530phongBitaro’s Party (JOI18_bitaro)C++17
0 / 100
2 ms5712 KiB
#include<bits/stdc++.h> using namespace std; #define fi first #define se second #define ll long long #define task "code" const int ar = 1e5 + 5; const ll mod = 1e9 + 7; const int block = 100; int n, m, q; vector<int> ad[ar]; vector<pair<int, int>> lis[ar]; int x[ar]; bool check[ar]; int dp[ar]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); if (fopen(task".inp", "r")) { freopen(task".inp", "r", stdin); freopen(task".out", "w", stdout); } cin >> n >> m >> q; for (int i = 1; i <= m; i++) { int s, e; cin >> s >> e; ad[e].push_back(s); } for (int i = 1; i <= n; i++) { lis[i] = {{0, i}}; for (auto j : ad[i]) { for (auto [w, u] : lis[j]) { lis[i].push_back({w + 1, u}); } } sort(lis[i].begin(), lis[i].end(), greater<pair<int, int>>()); while(lis[i].size() > block) lis[i].pop_back(); } while(q--) { int t, y; cin >> t >> y; for (int i = 1; i <= y; i++) { cin >> x[i]; check[x[i]] = true; } if (y >= block) { for (int i = 1; i <= t; i++) { dp[i] = 0; for (auto j : ad[i]) { if (check[j]) { if (dp[j] > 0) dp[i] = max(dp[i], dp[j] + 1); } else dp[i] = max(dp[i], dp[j] + 1); } } cout << dp[t] << '\n'; } else { for (auto [w, u] : lis[t]) { if (!check[u]) { cout << w << '\n'; break; } } } for (int i = 1; i <= y; i++) { check[x[i]] = false; } } }

Compilation message (stderr)

bitaro.cpp: In function 'int main()':
bitaro.cpp:25:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |         freopen(task".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
bitaro.cpp:26:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |         freopen(task".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...