이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
int temp = pj[j];
dp[i][j] += f(pi[i], j);
dp[i][j] += f(i, pj[j]);
dp[i][j] -= f(pi[i], pj[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';
}
}
컴파일 시 표준 에러 (stderr) 메시지
spy.cpp: In function 'int f(int, int)':
spy.cpp:23:6: warning: unused variable 'temp' [-Wunused-variable]
int temp = pj[j];
^~~~| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |