Submission #115912

#TimeUsernameProblemLanguageResultExecution timeMemory
115912njchung99스파이 (JOI13_spy)C++14
100 / 100
275 ms36780 KiB
#include<cstdio> #include<algorithm> #include<cstring> using namespace std; int dp[2010][2010]; int sum[2010][2010]; int p[2010], p1[2010]; int func(int here, int here1) { if (here == 0 || here1 == 0)return 0; int &ret = dp[here][here1]; if (ret != -1)return ret; ret = sum[here][here1] + func(p[here], here1) + func(here, p1[here1]) - func(p[here], p1[here1]); return ret; } int main() { memset(dp, -1, sizeof(dp)); int n, m; scanf("%d %d", &n,&m); for (int i = 1; i <= n; i++) scanf("%d %d", &p[i], &p1[i]); for (int i = 0; i < m; i++) { int q, w; scanf("%d %d", &q, &w); sum[q][w]++; } for (int i = 1; i <= n; i++) { printf("%d\n", func(i, i)); } }

Compilation message (stderr)

spy.cpp: In function 'int main()':
spy.cpp:19:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d", &n,&m);
  ~~~~~^~~~~~~~~~~~~~~~
spy.cpp:21:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d", &p[i], &p1[i]);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
spy.cpp:24:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d", &q, &w);
   ~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...