# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1045518 |
2024-08-06T04:54:18 Z |
juicy |
스파이 (JOI13_spy) |
C++17 |
|
94 ms |
20304 KB |
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif
const int N = 2e3 + 5;
int n, m;
int a[N], b[N], dp[N][N];
bool vis[N][N];
int f(int i, int j) {
if (i == 0 || j == 0) {
return 0;
}
int &res = dp[i][j];
if (vis[i][j]) {
return res;
}
vis[i][j] = 1;
return res += f(a[i], j) + f(i, b[j]) - f(a[i], b[j]);
}
int main() {
ios::sync_with_stdio(false); cin.tie(nullptr);
cin >> n >> m;
for (int i = 1; i <= n; ++i) {
cin >> a[i] >> b[i];
}
while (m--) {
int a, b; cin >> a >> b;
++dp[a][b];
}
for (int i = 1; i <= n; ++i) {
cout << f(i, i) << "\n";
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4952 KB |
Output is correct |
2 |
Correct |
1 ms |
4956 KB |
Output is correct |
3 |
Correct |
1 ms |
4956 KB |
Output is correct |
4 |
Correct |
0 ms |
4956 KB |
Output is correct |
5 |
Correct |
1 ms |
4956 KB |
Output is correct |
6 |
Correct |
1 ms |
4956 KB |
Output is correct |
7 |
Correct |
1 ms |
4956 KB |
Output is correct |
8 |
Correct |
1 ms |
4952 KB |
Output is correct |
9 |
Correct |
0 ms |
2396 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
42 ms |
20160 KB |
Output is correct |
2 |
Correct |
49 ms |
20224 KB |
Output is correct |
3 |
Correct |
4 ms |
19804 KB |
Output is correct |
4 |
Correct |
3 ms |
19548 KB |
Output is correct |
5 |
Correct |
4 ms |
19964 KB |
Output is correct |
6 |
Correct |
5 ms |
19896 KB |
Output is correct |
7 |
Correct |
26 ms |
19996 KB |
Output is correct |
8 |
Correct |
8 ms |
20060 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
94 ms |
20304 KB |
Output is correct |
2 |
Correct |
76 ms |
20052 KB |
Output is correct |
3 |
Correct |
39 ms |
19540 KB |
Output is correct |
4 |
Correct |
40 ms |
20052 KB |
Output is correct |
5 |
Correct |
45 ms |
19976 KB |
Output is correct |
6 |
Correct |
42 ms |
20048 KB |
Output is correct |
7 |
Correct |
67 ms |
20052 KB |
Output is correct |
8 |
Correct |
45 ms |
20048 KB |
Output is correct |