| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 124491 | DJ035 | 산만한 고양이 (KOI17_cat) | C++14 | 571 ms | 70064 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define MAXN 300005
#define pb push_back
typedef long long lld;
int N, M, C;
int dep[MAXN];
int U[MAXN], D[MAXN], F[MAXN];
vector <int> con[MAXN], child[MAXN];
void dfs(int n, int from)
{
for (int t: con[n]) if (t != from){
if (!dep[t]){
child[n].pb(t); dep[t] = dep[n]+1;
int tmp = U[n]; dfs(t, n); F[t] = U[n]-tmp;
U[n] += U[t]; D[n] += D[t];
}else if (dep[t] < dep[n]){
D[n]++; U[t]++;
}
}
}
int main()
{
scanf("%d%d", &N, &M);
for (int i=1;i<=M;i++){
int a, b; scanf("%d%d", &a, &b);
con[a].pb(b); con[b].pb(a);
}
dep[1] = 1; dfs(1, 0);
lld ans = 0;
for (int i=1;i<=N;i++){
bool skip = 0;
for (int t: child[i])
if (D[t]-F[t] > 1 || U[t]) skip = 1;
if (skip || M-(N-1)-D[i] != 0) continue;
ans += i;
}
printf("%lld\n", ans);
}
컴파일 시 표준 에러 (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... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
