# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
115912 | 2019-06-09T19:08:25 Z | njchung99 | 스파이 (JOI13_spy) | C++14 | 275 ms | 36780 KB |
#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
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 16 ms | 16640 KB | Output is correct |
2 | Correct | 15 ms | 16120 KB | Output is correct |
3 | Correct | 15 ms | 16376 KB | Output is correct |
4 | Correct | 14 ms | 16384 KB | Output is correct |
5 | Correct | 15 ms | 16632 KB | Output is correct |
6 | Correct | 15 ms | 16256 KB | Output is correct |
7 | Correct | 21 ms | 16640 KB | Output is correct |
8 | Correct | 15 ms | 16640 KB | Output is correct |
9 | Correct | 14 ms | 16128 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 85 ms | 22392 KB | Output is correct |
2 | Correct | 81 ms | 16476 KB | Output is correct |
3 | Correct | 20 ms | 19584 KB | Output is correct |
4 | Correct | 20 ms | 18432 KB | Output is correct |
5 | Correct | 28 ms | 22144 KB | Output is correct |
6 | Correct | 24 ms | 16328 KB | Output is correct |
7 | Correct | 96 ms | 22520 KB | Output is correct |
8 | Correct | 35 ms | 22524 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 222 ms | 36472 KB | Output is correct |
2 | Correct | 169 ms | 20728 KB | Output is correct |
3 | Correct | 116 ms | 32504 KB | Output is correct |
4 | Correct | 122 ms | 36780 KB | Output is correct |
5 | Correct | 159 ms | 36220 KB | Output is correct |
6 | Correct | 103 ms | 21272 KB | Output is correct |
7 | Correct | 275 ms | 36216 KB | Output is correct |
8 | Correct | 196 ms | 36420 KB | Output is correct |