Submission #49575

#TimeUsernameProblemLanguageResultExecution timeMemory
49575daniel_02Bitaro’s Party (JOI18_bitaro)C++17
14 / 100
2045 ms8004 KiB
#include <bits/stdc++.h> #define pb push_back #define fr first #define sc second using namespace std; const int N = 1e5 + 7; const int inf = 1e9 + 7; priority_queue<pair<int, int>>q; vector<pair<int, int>>g[N]; bool busy[N]; int d[N]; main() { int n, m, Q; cin >> n >> m >> Q; for (int i = 1; i <= m; i ++) { int u, v; scanf("%d%d", &u, &v); g[v].pb({u, 1}); } while (Q--) { int t, k, mx; scanf("%d%d", &t, &k); for (int i = 0; i < k; i++) { int a; scanf("%d", &a); busy[a] = 1; } for (int i = 1; i <= n; i++) d[i] = -inf; q.push({t, 0}); d[t] = 0; while (!q.empty()) { int v = q.top().fr, cs = q.top().sc * -1; q.pop(); if (d[v] < cs)continue; for (int i = 0; i < g[v].size(); i++) { int to = g[v][i].fr, cost = g[v][i].sc; if (d[to] < cost + d[v]) { // cout << v << " " << to << " " << d[v] << endl; d[to] = cost + d[v]; q.push({to, -d[v]}); } } } mx = -1; for (int i = 1; i <= n; i++) { if (!busy[i] && d[i] != -inf) { mx = max(mx, d[i]); } } if (mx == -1 || mx == -inf) { cout << -1 << endl; continue; } cout << mx << endl; memset(busy, 0, sizeof(busy)); } }

Compilation message (stderr)

bitaro.cpp:17:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main()
      ^
bitaro.cpp: In function 'int main()':
bitaro.cpp:56:31: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for (int i = 0; i < g[v].size(); i++)
                             ~~^~~~~~~~~~~~~
bitaro.cpp:27:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d", &u, &v);
         ~~~~~^~~~~~~~~~~~~~~~
bitaro.cpp:36:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d", &t, &k);
         ~~~~~^~~~~~~~~~~~~~~~
bitaro.cpp:41:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%d", &a);
             ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...