| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 122170 | wilwxk | Cats or Dogs (JOI18_catdog) | C++11 | 3042 ms | 7528 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "catdog.h"
#include <bits/stdc++.h>
using namespace std;
const int MAXN=1e5+5;
vector<int> g[MAXN];
int dp[MAXN][2];
int cor[MAXN];
int n;
void dfs(int cur, int p) {
dp[cur][0]=dp[cur][1]=0;
for(auto viz : g[cur]) {
if(viz==p) continue;
dfs(viz, cur);
dp[cur][0]+=min(dp[viz][0], dp[viz][1]+1);
dp[cur][1]+=min(dp[viz][1], dp[viz][0]+1);
}
if(cor[cur]!=-1) dp[cur][!cor[cur]]=n+n;
}
void initialize(int N, std::vector<int> A, std::vector<int> B) {
n=N;
for(int i=0; i<A.size(); i++) g[A[i]].push_back(B[i]), g[B[i]].push_back(A[i]);
memset(cor, -1, sizeof(cor));
}
int cat(int v) {
cor[v]=0;
dfs(1, 1);
return min(dp[1][0], dp[1][1]);
}
int dog(int v) {
cor[v]=1;
dfs(1, 1);
return min(dp[1][0], dp[1][1]);
}
int neighbor(int v) {
cor[v]=-1;
dfs(1, 1);
return min(dp[1][0], dp[1][1]);
}
컴파일 시 표준 에러 (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... | ||||
