# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
142788 |
2019-08-11T03:48:08 Z |
gs18103 |
스파이 (JOI13_spy) |
C++14 |
|
451 ms |
40512 KB |
#include <bits/stdc++.h>
#define fi first
#define se second
#define all(v) (v).begin(), (v).end()
#define eb emplace_back
#define fastio ios::sync_with_stdio(false); cin.tie(NULL)
#define INF 2000000000;
#define LINF 1000000000000000000LL
#define mod 1000000007
using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
int dp[2020][2020], cnt[2020][2020], pj[2020], pi[2020];
bool chk[2020][2020];
int f(int i, int j) {
if(i == 0 || j == 0) return 0;
if(chk[i][j]) return dp[i][j];
chk[i][j] = true;
dp[i][j] += f(i, pj[j]);
dp[i][j] += f(pi[i], j);
dp[i][j] += cnt[i][j];
return dp[i][j];
}
int main() {
fastio;
int n, m;
cin >> n >> m;
for(int i = 1, u, v; i <= n; i++) {
cin >> u >> v;
pj[i] = u;
pi[i] = v;
}
for(int i = 1; i <= m; i++) {
int r, s;
cin >> r >> s;
cnt[s][r]++;
}
for(int i = 1; i <= n; i++) {
cout << f(i, i) << '\n';
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
2168 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
317 ms |
26612 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
451 ms |
40512 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |