# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|
1045518 | | juicy | 스파이 (JOI13_spy) | C++17 | | 94 ms | 20304 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |