Submission #112492

#TimeUsernameProblemLanguageResultExecution timeMemory
112492njchung99스파이 (JOI13_spy)C++14
0 / 100
216 ms31968 KiB
#include<cstdio> #include<cstring> #include<algorithm> #include<vector> using namespace std; int dp[2010][2010]; int sum[2010][2010]; int p[2010]; int 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[here]); return ret; } int main() { memset(dp, -1, sizeof(dp)); int n, m; scanf("%d %d", &n, &m); for (int i = 1; i <= n; i++) { int q, w; scanf("%d %d", &q, &w); p[i] = q; p1[i] = w; } for (int i = 1; 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:22: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:25:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d", &q, &w);
   ~~~~~^~~~~~~~~~~~~~~~~
spy.cpp:30: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...