답안 #1086029

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1086029 2024-09-09T10:10:41 Z byunjaewoo Cats or Dogs (JOI18_catdog) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#define int long long
using namespace std;

const int N=100010, INF=1e9;
int n, q, a[N], d1[N], d2[N];
vector<int> adj[N];

void dfs(int curr, int prev) {
    d1[curr]=d2[curr]=0;
    for(int next:adj[curr]) if(next!=prev) {
        dfs(next, curr);
        d1[curr]+=min(d1[next], d2[next]+1), d2[curr]+=min(d2[next], d1[curr]+1);
    }
    if(a[curr]==1) d2[curr]=INF;
    if(a[curr]==2) d1[curr]=INF;
}

signed main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin>>n;
    for(int i=1; i<n; i++) {
        int u, v; cin>>u>>v;
        adj[u].push_back(v), adj[v].push_back(u);
    }
    cin>>q;
    while(q--) {
        int o, k; cin>>o>>k;
        a[k]=o%3;
        dfs(1, 0);
        cout<<min(d1[1], d2[1])<<"\n";
    }
    return 0;
}

Compilation message

/usr/bin/ld: /tmp/ccP3AabN.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccSBcQ5M.o:catdog.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccP3AabN.o: in function `main':
grader.cpp:(.text.startup+0x1e2): undefined reference to `initialize(int, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >)'
/usr/bin/ld: grader.cpp:(.text.startup+0x219): undefined reference to `neighbor(int)'
/usr/bin/ld: grader.cpp:(.text.startup+0x25e): undefined reference to `dog(int)'
/usr/bin/ld: grader.cpp:(.text.startup+0x269): undefined reference to `cat(int)'
collect2: error: ld returned 1 exit status