# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
112492 | 2019-05-20T08:46:40 Z | njchung99 | 스파이 (JOI13_spy) | C++14 | 216 ms | 31968 KB |
#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
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 13 ms | 16612 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 76 ms | 22400 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 216 ms | 31968 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |