답안 #126170

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
126170 2019-07-07T07:46:53 Z arnold518 Amusement Park (JOI17_amusement_park) C++14
컴파일 오류
0 ms 0 KB
#include "Ioi.h"
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MAXN = 1e4;

static int N, M, P;
static vector<int> adj[MAXN+10], tree[MAXN+10];
static int num[MAXN+10], cnt=0;
static int par[MAXN+10], deg[MAXN+10], col[MAXN+10];
static bool live[MAXN+10], togo[MAXN+10];
static ll ans;

static void dfs1(int now)
{
    num[now]=cnt++;
    if(num[now]<60)
    {
        live[now]=true;
        col[now]=num[now];
    }

    for(int nxt : adj[now])
    {
        if(num[nxt]!=-1) continue;
        dfs1(nxt);

        if(num[now]<60 && num[nxt]<60) deg[now]++, deg[nxt]++;
        tree[now].push_back(nxt);
        tree[nxt].push_back(now);
        par[nxt]=now;
    }
}

static bool vis[MAXN+10];
static set<int> S;
static void dfs2(int now)
{
    vis[now]=true;

    int leaf;
    vector<int> V;
    if(num[now]>=60)
    {
        for(auto it : S) if(it!=par[now]) { leaf=it; break; }
        S.erase(leaf);
        live[leaf]=false; col[now]=col[leaf];
        for(int nxt : tree[leaf])
        {
            if(!live[nxt]) continue;
            V.push_back(nxt);
            deg[leaf]--;
            deg[nxt]--;
            if(deg[nxt]==1) S.insert(nxt);
        }

        deg[par[now]]++;
        deg[now]++;
        S.insert(now);
    }

    if(now==P)
    {
        int i, j;
        for(i=0; i<N; i++) togo[i]=live[i];
    }

    for(int nxt : tree[now])
    {
        if(vis[nxt]) continue;
        dfs2(nxt);
    }

    if(num[now]>=60)
    {
        deg[par[now]]--;
        deg[now]--;
        S.erase(now);
        S.insert(leaf);
        live[leaf]=true;
        for(int it : V)
        {
            if(deg[it]==1) S.erase(it);
            deg[leaf]++; deg[it]++;
        }
    }
}

static void makeTree(int A[], int B[])
{
    int i, j;

    for(i=0; i<M; i++)
    {
        adj[A[i]].push_back(B[i]);
        adj[B[i]].push_back(A[i]);
    }
    for(i=0; i<N; i++) sort(adj[i].begin(), adj[i].end());

    memset(num, -1, sizeof(num));
    dfs1(0);

    for(i=0; i<N; i++) if(deg[i]==1) S.insert(i);
}

static void dfs3(int now)
{
    togo[now]=false;
    for(int nxt : tree[now])
    {
        if(!togo[nxt]) continue;
        ans|=(ll)Move(nxt)<<col[nxt];
        dfs3(nxt);
        ans|=(ll)Move(now)<<col[now];
    }
}

ll Ioi(int n, int m, int A[], int B[], int p, int V, int T)
{
    N=n; M=m; P=p;
    makeTree(A, B);
    dfs3(P);
    return ans;
}



    

Compilation message

Joi.cpp: In function 'void dfs2(int)':
Joi.cpp:68:16: warning: unused variable 'j' [-Wunused-variable]
         int i, j;
                ^
Joi.cpp: In function 'void makeTree(int*, int*)':
Joi.cpp:95:12: warning: unused variable 'j' [-Wunused-variable]
     int i, j;
            ^
Joi.cpp: In function 'void dfs3(int)':
Joi.cpp:116:18: error: 'Move' was not declared in this scope
         ans|=(ll)Move(nxt)<<col[nxt];
                  ^~~~
Joi.cpp:116:18: note: suggested alternative: 'live'
         ans|=(ll)Move(nxt)<<col[nxt];
                  ^~~~
                  live

/tmp/ccIGTvxn.o: In function `main':
grader_ioi.cpp:(.text.startup+0x36a): undefined reference to `Ioi(int, int, int*, int*, int, int, int)'
collect2: error: ld returned 1 exit status