제출 #1063420

#제출 시각아이디문제언어결과실행 시간메모리
1063420nima_aryanBitaro’s Party (JOI18_bitaro)C++17
100 / 100
1107 ms127664 KiB
/** * author: NimaAryan * created: 2024-08-17 20:59:09 **/ #include <bits/stdc++.h> using namespace std; #ifdef LOCAL #include "algo/debug.h" #endif using i64 = long long; constexpr int SQ = 100; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int N, M, Q; cin >> N >> M >> Q; vector<vector<int>> g(N + 1); for (int i = 0; i < M; ++i) { int s, e; cin >> s >> e; --s, --e; g[e].push_back(s); } vector<vector<pair<int, int>>> f(N); bitset<100000> ex; for (int x = 0; x < N; ++x) { vector<pair<int, int>> cf{{ -1, x}}; for (int y : g[x]) { cf.insert(cf.end(), f[y].begin(), f[y].end()); } sort(cf.begin(), cf.end(), greater<>()); for (int i = 0; i < cf.size() && f[x].size() < SQ; ++i) { auto [d, s] = cf[i]; d += 1; if (ex.test(s)) { continue; } ex.set(s); f[x].emplace_back(d, s); } ex.reset(); } vector<bool> ban(N); while (Q--) { int t, y; cin >> t >> y; --t; vector<int> C(y); for (int i = 0; i < y; ++i) { cin >> C[i]; --C[i]; ban[C[i]] = true; } if (y >= SQ) { vector<int> dp(t + 1); for (int x = 0; x <= t; ++x) { dp[x] = ban[x] ? -N : 0; for (int y : g[x]) { dp[x] = max(dp[x], dp[y] + 1); } } cout << max(-1, dp[t]) << "\n"; } else { int ans = -1; for (auto [d, s] : f[t]) { if (!ban[s]) { ans = max(ans, d); } } cout << ans << "\n"; } for (int i = 0; i < y; ++i) { ban[C[i]] = false; } } return 0; }

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

bitaro.cpp: In function 'int main()':
bitaro.cpp:40:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |     for (int i = 0; i < cf.size() && f[x].size() < SQ; ++i) {
      |                     ~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...