# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
112493 | 2019-05-20T08:47:52 Z | njchung99 | 스파이 (JOI13_spy) | C++14 | 278 ms | 36600 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[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++) { 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 | Correct | 15 ms | 16640 KB | Output is correct |
2 | Correct | 14 ms | 16128 KB | Output is correct |
3 | Correct | 14 ms | 16512 KB | Output is correct |
4 | Correct | 14 ms | 16384 KB | Output is correct |
5 | Correct | 14 ms | 16640 KB | Output is correct |
6 | Correct | 13 ms | 16256 KB | Output is correct |
7 | Correct | 14 ms | 16640 KB | Output is correct |
8 | Correct | 15 ms | 16640 KB | Output is correct |
9 | Correct | 13 ms | 16128 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 86 ms | 22272 KB | Output is correct |
2 | Correct | 76 ms | 16504 KB | Output is correct |
3 | Correct | 20 ms | 19456 KB | Output is correct |
4 | Correct | 18 ms | 18432 KB | Output is correct |
5 | Correct | 26 ms | 22036 KB | Output is correct |
6 | Correct | 24 ms | 16384 KB | Output is correct |
7 | Correct | 95 ms | 22528 KB | Output is correct |
8 | Correct | 40 ms | 22520 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 235 ms | 31992 KB | Output is correct |
2 | Correct | 171 ms | 20732 KB | Output is correct |
3 | Correct | 115 ms | 32504 KB | Output is correct |
4 | Correct | 122 ms | 36600 KB | Output is correct |
5 | Correct | 168 ms | 36360 KB | Output is correct |
6 | Correct | 99 ms | 21236 KB | Output is correct |
7 | Correct | 278 ms | 36520 KB | Output is correct |
8 | Correct | 193 ms | 36216 KB | Output is correct |