답안 #1055705

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1055705 2024-08-13T03:57:03 Z shjeong 참나무 (IOI23_beechtree) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pi;
#define all(x) x.begin(),x.end()
#define rll(x) x.rbegin(),x.rend()
ll n, m;
vector<ll> p, c;
vector<int> ans;
vector<ll> adj[202020];
void dfs(ll x){
    for(auto next : adj[x]){
        dfs(next);
    }
    set<ll> st;
    bool flag = 1;
    for(auto next : adj[x]){
        if(st.find(c[next]) != st.end()){
            flag = 0;
            break;
        }
        st.insert(c[next]);
    }
    ans[x] = flag;
    if(x==0 and flag){
        vector<pair<ll,map<ll,ll>>> v;
        for(auto next : adj[x]){
            if(!ans[next]){ans[x] = 0; return;}
            ll cnt = 0; map<ll,ll> mp;
            for(auto nnext : adj[next])cnt++, mp[c[nnext]]++;
            v.push_back({cnt,mp});
        }
        sort(rll(v));
        for(int i = 1 ; i < v.size() ; i++){
            for(auto [a,b] : v[i].second){
                if(v[i-1].second[a] < b){
                    ans[x] = 0;
                    return;
                }
                if(v[i-1].first == v[i-1].first and v[i-1].second[a] != b){
                    ans[x] = 0;
                    return;
                }
            }
        }
    }
}

Compilation message

beechtree.cpp: In function 'void dfs(ll)':
beechtree.cpp:34:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, std::map<long long int, long long int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |         for(int i = 1 ; i < v.size() ; i++){
      |                         ~~^~~~~~~~~~
/usr/bin/ld: /tmp/ccE8jGeQ.o: in function `main':
grader.cpp:(.text.startup+0x27d): undefined reference to `beechtree(int, int, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status