Submission #448228

#TimeUsernameProblemLanguageResultExecution timeMemory
448228hizuna스파이 (JOI13_spy)C++17
100 / 100
228 ms16452 KiB
#include <bits/stdc++.h> using namespace std; using lint = long long; vector<int> child[2][2003]; int f[2003][2003], N, M, a, r, s, root[2]; void dfsi(int u) { for(auto v : child[0][u]) { for(int i = 0; i < N; i++) { f[v][i] += f[u][i]; } dfsi(v); } } void dfsj(int u) { for(auto v : child[1][u]) { for(int i = 0; i < N; i++) { f[i][v] += f[i][u]; } dfsj(v); } } int main() { scanf("%d%d", &N, &M); for(int i = 0; i < N; i++) { for(int j = 0; j <= 1; j++) { scanf("%d", &a); if(a == 0) root[j] = i; else child[j][--a].push_back(i); } } for(int i = 0; i < M; i++) { scanf("%d%d", &r, &s); f[--r][--s]++; } dfsi(root[0]); dfsj(root[1]); for(int i = 0; i < N; i++) { printf("%d\n", f[i][i]); } return 0; }

Compilation message (stderr)

spy.cpp: In function 'int main()':
spy.cpp:28:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   28 |     scanf("%d%d", &N, &M);
      |     ~~~~~^~~~~~~~~~~~~~~~
spy.cpp:31:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   31 |             scanf("%d", &a);
      |             ~~~~~^~~~~~~~~~
spy.cpp:37:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   37 |         scanf("%d%d", &r, &s);
      |         ~~~~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...