Submission #981126

#TimeUsernameProblemLanguageResultExecution timeMemory
981126blackslexBitaro’s Party (JOI18_bitaro)C++17
0 / 100
1 ms348 KiB
#include<bits/stdc++.h> using namespace std; int n, m, q, x, y, t, r; int main() { scanf("%d %d %d", &n, &m, &q); vector<vector<int>> v(n + 5, vector<int>()); while (m--) scanf("%d %d", &x, &y), v[x].emplace_back(y); scanf("%d %d", &t, &r); vector<int> c(r), dp(n + 5); vector<bool> f(n + 5), f2(n + 5); for (auto &e: c) scanf("%d", &e), f[e] = 1; function<void(int, int)> dfs = [&] (int cur, int par) { if (f2[cur]) return; f2[cur] = 1; for (auto &e: v[cur]) { if (par == e || e > t) continue; dfs(e, cur); dp[cur] = max(dp[cur], dp[e] + 1); } }; int ans = -1; for (int i = 1; i <= t; i++) if (!f[i]) dfs(i, 0), ans = max(ans, dp[i]); printf("%d", ans); }

Compilation message (stderr)

bitaro.cpp: In lambda function:
bitaro.cpp:16:9: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   16 |         if (f2[cur]) return; f2[cur] = 1;
      |         ^~
bitaro.cpp:16:30: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   16 |         if (f2[cur]) return; f2[cur] = 1;
      |                              ^~
bitaro.cpp: In function 'int main()':
bitaro.cpp:8:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |     scanf("%d %d %d", &n, &m, &q);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
bitaro.cpp:10:22: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |     while (m--) scanf("%d %d", &x, &y), v[x].emplace_back(y);
      |                 ~~~~~^~~~~~~~~~~~~~~~~
bitaro.cpp:11:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |     scanf("%d %d", &t, &r);
      |     ~~~~~^~~~~~~~~~~~~~~~~
bitaro.cpp:14:27: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |     for (auto &e: c) scanf("%d", &e), f[e] = 1;
      |                      ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...