Submission #1037322

#TimeUsernameProblemLanguageResultExecution timeMemory
1037322ThommyDBBitaro’s Party (JOI18_bitaro)C++17
0 / 100
2068 ms295888 KiB
#include <bits/stdc++.h> using namespace std; bool compare(pair<int, int>& a, pair<int, int>& b){ return a.second > b.second; } signed main() { int n, m ,q; cin >> n >> m >> q; vector<vector<int>> adj(n+1); int s, e; for(int i = 1; i <= m; i++) { cin >> s >> e; adj[e].push_back(s); } vector<int> pos(n + 1, -1); vector<vector<pair<int, int>>> len(n+1); for(int i = 1; i < n+1; i++) { len[i].push_back({i, 0}); for (auto u : adj[i]) { for (auto x : len[u]) { if (pos[x.first] != -1 && x.second+1 > len[i][pos[x.first]].second) len[i][pos[x.first]].second=x.second+1; else len[i].push_back({x.first, x.second + 1}); } sort(len[i].begin(), len[i].end(), compare); for(int j = 0; j < len[i].size(); j++) { pos[len[i][j].first] = j; } } for(int j = 0; j < len[i].size(); j++) { pos[len[i][j].first] = -1; } } vector<int> dp(n + 1, -1); vector<bool> busy(n+1); for(int i = 1; i <q+1; i++) { int src, t; cin >> src >> t; vector<int> c(t); for (int j = 0; j < t; j++) { cin >> c[j]; busy[c[j]] = true; } int ans = -1; for (auto x : len[src]) { if (!busy[x.first]) { ans = x.second; break; } } cout << (ans < 0 ? -1 : ans) << "\n"; for (int u : c) { busy[u] = false; } } }

Compilation message (stderr)

bitaro.cpp: In function 'int main()':
bitaro.cpp:29: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]
   29 |             for(int j = 0; j < len[i].size(); j++) {
      |                            ~~^~~~~~~~~~~~~~~
bitaro.cpp:33:26: 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 |         for(int j = 0; j < len[i].size(); j++) {
      |                        ~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...