Submission #383374

#TimeUsernameProblemLanguageResultExecution timeMemory
383374LucaDantasBitaro’s Party (JOI18_bitaro)C++17
0 / 100
3 ms3052 KiB
// Q = 1, brute dfs solution #include <bits/stdc++.h> using namespace std; constexpr int maxn = 1e5+10; vector<int> g[maxn]; // reverse bool busy[maxn], tem[maxn]; int dp[maxn]; int dfs(int u) { if(dp[u] != -1) return dp[u]; tem[u] = !busy[u]; int& ans = dp[u]; ans = 0; for(int v : g[u]) ans = max(ans, dfs(v)+tem[v]), tem[u] |= tem[v]; return ans; } int main() { int n, m, q; scanf("%d %d %d", &n, &m, &q); // assert(q == 1); for(int i = 0, a, b; i < m; i++) scanf("%d %d", &b, &a), g[a].push_back(b); memset(dp, -1, sizeof dp); int t, y; scanf("%d %d", &t, &y); for(int i = 0, a; i < y; i++) scanf("%d", &a), busy[a] = 1; printf("%d\n", dfs(t)); }

Compilation message (stderr)

bitaro.cpp: In function 'int main()':
bitaro.cpp:24:20: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   24 |  int n, m, q; scanf("%d %d %d", &n, &m, &q); // assert(q == 1);
      |               ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
bitaro.cpp:26:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   26 |   scanf("%d %d", &b, &a), g[a].push_back(b);
      |   ~~~~~^~~~~~~~~~~~~~~~~
bitaro.cpp:28:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   28 |  int t, y; scanf("%d %d", &t, &y);
      |            ~~~~~^~~~~~~~~~~~~~~~~
bitaro.cpp:30:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   30 |   scanf("%d", &a), busy[a] = 1;
      |   ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...