Submission #966671

#TimeUsernameProblemLanguageResultExecution timeMemory
966671PringBitaro’s Party (JOI18_bitaro)C++17
14 / 100
1626 ms267344 KiB
#include <bits/stdc++.h> #pragma GCC optimize("O3","unroll-loops") #pragma GCC target("avx2","popcnt","sse4","abm") using namespace std; #ifdef MIKU string dbmc = "\033[1;38;2;57;197;187m", dbrs = "\033[0m"; #define debug(x...) cout << dbmc << "[" << #x << "]: ", dout(x) void dout() { cout << dbrs << endl; } template <typename T, typename ...U> void dout(T t, U ...u) { cout << t << (sizeof...(u) ? ", " : ""); dout(u...); } #else #define debug(...) 39 #endif #define fs first #define sc second #define mp make_pair #define FOR(i, j, k) for (int i = j, Z = k; i < Z; i++) using ll = long long; typedef pair<int, int> pii; const int MXN = 100005, K = 280, INF = 1e9; int n, m, q; vector<int> edge[MXN], edge_inv[MXN]; bitset<MXN> b; int dis[MXN]; vector<pii> w[MXN]; void MERGE(vector<pii> &a, vector<pii> &b, vector<pii> &c) { c.clear(); for (int i = 0, j = 0; i < a.size() || j < b.size(); ) { if (i == a.size()) c.push_back(b[j++]); else if (j == b.size()) c.push_back(a[i++]); else if (a[i].sc < b[i].sc) c.push_back(b[j++]); else c.push_back(a[i++]); } } void DP(int id) { vector<pii> a, bb, c; a.push_back(mp(id, 0)); for (auto pre : edge_inv[id]) { for (auto [id, len] : w[pre]) bb.push_back(mp(id, len + 1)); MERGE(a, bb, c); a.clear(); bb.clear(); for (auto [id, len] : c) { if (b[id]) continue; b[id] = true; a.push_back(mp(id, len)); } for (auto &[i, _] : a) b[i] = false; while (a.size() > K + 1) a.pop_back(); } w[id] = a; } void TS(int sr) { fill(dis + 1, dis + n + 1, -INF); dis[sr] = 0; for (int id = sr - 1; id; id--) { for (auto &i : edge[id]) dis[id] = max(dis[id], dis[i] + 1); } } int calc(int t, vector<int> &v) { if (v.size() <= K) { for (auto [i, x] : w[t]) { if (b[i]) continue; return x; } return -1; } else { TS(t); int ans = -1; FOR(i, 1, t + 1) { if (b[i]) continue; ans = max(ans, dis[i]); } return ans; } return 0; } void miku() { cin >> n >> m >> q; while (m--) { int x, y; cin >> x >> y; edge[x].push_back(y); edge_inv[y].push_back(x); } FOR(i, 1, n + 1) DP(i); while (q--) { int t, y; vector<int> v; cin >> t >> y; v.resize(y); for (auto &i : v) { cin >> i; b[i] = true; } cout << calc(t, v) << '\n'; for (auto &i : v) { b[i] = false; } } // FOR(i, 1, n + 1) { // debug(i); // for (auto &[id, x] : w[i]) debug(id, x); // } } int32_t main() { cin.tie(0) -> sync_with_stdio(false); cin.exceptions(cin.failbit); miku(); return 0; }

Compilation message (stderr)

bitaro.cpp: In function 'void MERGE(std::vector<std::pair<int, int> >&, std::vector<std::pair<int, int> >&, std::vector<std::pair<int, int> >&)':
bitaro.cpp:32:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |     for (int i = 0, j = 0; i < a.size() || j < b.size(); ) {
      |                            ~~^~~~~~~~~~
bitaro.cpp:32:46: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |     for (int i = 0, j = 0; i < a.size() || j < b.size(); ) {
      |                                            ~~^~~~~~~~~~
bitaro.cpp:33:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |         if (i == a.size()) c.push_back(b[j++]);
      |             ~~^~~~~~~~~~~
bitaro.cpp:34:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |         else if (j == b.size()) c.push_back(a[i++]);
      |                  ~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...