| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 34034 | ToMoClone | 스파이 (JOI13_spy) | C++14 | 233 ms | 17952 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/*input
3 4
0 2
1 0
2 2
1 1
2 1
2 3
3 2
*/
#include <bits/stdc++.h>
using namespace std;
const int N = 2007;
int startI[N], finishI[N], par[N], ans[N][N], n, m, rootI, cnt;
vector<int> childI[N];
void dfs(int u){
startI[u] = ++cnt;
for(auto v:childI[u]) dfs(v);
finishI[u] = cnt + 1;
}
int main(){
scanf("%d%d", &n, &m);
for(int i = 1; i <= n; ++i){
int a, b; scanf("%d%d", &a, &b);
childI[b].push_back(i);
if(b == 0) rootI = i;
par[i] = a;
}
dfs(rootI);
for(int i = 1; i <= m; ++i){
int a, b; scanf("%d%d", &a, &b);
++ans[a][startI[b]];
--ans[a][finishI[b]];
}
for(int i = 1; i <= n; ++i)
for(int j = 1; j <= n; ++j)
ans[i][j] += ans[i][j - 1];
for(int i = 1; i <= n; ++i){
int k = i, res = 0;
while(k != 0) res += ans[k][startI[i]], k = par[k];
printf("%d\n", res);
}
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
