제출 #47755

#제출 시각아이디문제언어결과실행 시간메모리
47755daniel_02Bitaro’s Party (JOI18_bitaro)C++17
0 / 100
5 ms3080 KiB
#include <bits/stdc++.h> #define pb push_back #define fr first #define sc second using namespace std; const int N = 1e5 + 7; priority_queue<pair<int, int>>q; vector<pair<int, int>>g[N]; bool busy[N], us[N]; int mx; void dfs(int v, int d = 0) { if (!busy[v]) mx = max(mx, d); if (us[v])return; us[v] = 1; for (int i = 0; i < g[v].size(); i++) { int to = g[v][i].fr; dfs(to, d + 1); } } 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; scanf("%d%d", &t, &k); for (int i = 0; i < k; i++) { int a; scanf("%d", &a); busy[a] = 1; } dfs(t); if (mx == 0) { if (busy[t]) { cout << -1 << endl; continue; } cout << 0 << endl; continue; } cout << mx << endl; memset(us, 0, sizeof(us)); memset(busy, 0, sizeof(busy)); mx = 0; } }

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

bitaro.cpp: In function 'void dfs(int, int)':
bitaro.cpp:25:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < g[v].size(); i++)
                     ~~^~~~~~~~~~~~~
bitaro.cpp: At global scope:
bitaro.cpp:32:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main()
      ^
bitaro.cpp: In function 'int main()':
bitaro.cpp:42: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:51: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:56: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...