Submission #57792

#TimeUsernameProblemLanguageResultExecution timeMemory
57792YaDon4ickSynchronization (JOI13_synchronization)C++14
0 / 100
180 ms15112 KiB
//By Don4ick //#define _GLIBCXX_DEBUG #include <bits/stdc++.h> typedef long long ll; typedef long double ld; typedef unsigned int ui; #define forn(i, n) for (int i = 1; i <= n; i++) #define pb push_back #define all(x) x.begin(), x.end() #define y1 qwer1234 const double PI = acos(-1.0); const int DIR = 4; const int X[] = {1, 0, -1, 0}; const int Y[] = {0, 1, 0, -1}; const int N = (int)2e5 + 228; using namespace std; int n, m, q, l[N], r[N], st[N]; vector < pair < int, int > > g[N]; int dfs(int v, int t, int pr) { int res = 1; for (auto e : g[v]) { int to = e.first, id = e.second; if (to == pr) continue; if (l[id] > t) continue; res += dfs(to, min(t, r[id]), v); } return res; } int main() { //ios_base::sync_with_stdio(false); //cin.tie(NULL); //cout.tie(NULL); //freopen(".in", "r", stdin); //freopen(".out", "w", stdout); //~read scanf("%d%d%d", &n, &m, &q); forn(i, n - 1) { int v, u; scanf("%d%d", &v, &u); g[v].pb({u, i}), g[u].pb({v, i}); } forn(i, m) { int e; scanf("%d", &e); if (st[e]) { l[e] = st[e], r[e] = i; st[e] = 0; } else { st[e] = i; l[e] = i, r[e] = m; } } //~solve forn(i, q) { int v; scanf("%d", &v); printf("%d\n", dfs(v, m, -1)); } return 0; }

Compilation message (stderr)

synchronization.cpp: In function 'int main()':
synchronization.cpp:52:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d%d", &n, &m, &q);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~
synchronization.cpp:56:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d", &v, &u);
   ~~~~~^~~~~~~~~~~~~~~~
synchronization.cpp:62:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &e); 
   ~~~~~^~~~~~~~~~
synchronization.cpp:78:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &v);
   ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...