답안 #72777

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
72777 2018-08-26T23:55:53 Z RezwanArefin01 Amusement Park (JOI17_amusement_park) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#include "Joi.h"
using namespace std;

const int N = 10010; 
vector<int> g[N], adj[N], t[N]; 
int vis[N], p[N], num[N], cnt, d[N]; 

void gen(int u) {
    vis[u] = 1; 
    for(int v : g[u]) if(!vis[v]) {
        adj[u].push_back(v);
        adj[v].push_back(u); 
        gen(v);
    }
}

vector<int> q; 
void dfs(int u, int par) {
    q.push_back(u);     
    p[u] = par; 
    num[u] = cnt++; 
    for(int v : adj[u]) if(v - par && cnt < 10) 
        dfs(v, u); 
}
bool has(vector<int> &T, int x) {
    return binary_search(T.begin(), T.end(), x); 
}
long long X;  
void solve(int u, int par) {
    for(int v : adj[u]) if(v - par && has(t[u], v)) {
        int x = move(v); 
        if(x) X |= 1 << num[v]; 
        dfs(v, u); 
    } if(par + 1) move(par); 
}

long long Ioi(int N, int M, int A[], int B[], int P, int V, int T) {
    for(int i = 0; i < M; i++) {
        g[A[i]].push_back(B[i]); 
        g[B[i]].push_back(A[i]); 
    } gen(0);
    memset(num, -1, sizeof num);
    dfs(0, -1); 
    sort(q.begin(), q.end());
    for(int u : q) t[u] = q; 
    for(int i = 0; i < q.size(); i++) {
       int u = q[i]; 
       for(int v : adj[u]) if(num[v] == -1) {
           vector<int> T = t[u]; 
           for(int w : T) {
               int x = p[w]; 
               if(x != -1 && has(T, x)) 
                   d[w]++, d[x]++; 
           }
           int x = -1; 
           for(int w : T) if(w != u && d[w] == 1) x = w; 
           num[v] = num[x]; 
           for(int w : T) if(w != x) t[v].push_back(w);
           t[v].push_back(v); 
           p[v] = u; 
           q.push_back(v); 
           for(int w : T) d[w] = 0;
           sort(t[v].begin(), t[v].end()); 
        }
    }
    
    if(V) X = 1 << num[P]; 
    solve(P, -1); 
    return X; 
}
#include <bits/stdc++.h>
#include "Joi.h"
using namespace std;

const int N = 10010; 
vector<int> g[N], adj[N], t[N]; 
int vis[N], p[N], num[N], cnt, d[N]; 

void gen(int u) {
    vis[u] = 1; 
    for(int v : g[u]) if(!vis[v]) {
        adj[u].push_back(v);
        adj[v].push_back(u); 
        gen(v);
    }
}

vector<int> q; 
void dfs(int u, int par) {
    q.push_back(u);     
    p[u] = par; 
    num[u] = cnt++; 
    for(int v : adj[u]) if(v - par && cnt < 10) 
        dfs(v, u); 
}
bool has(vector<int> &T, int x) {
    return binary_search(T.begin(), T.end(), x); 
}
long long X;  
void solve(int u, int par) {
    for(int v : adj[u]) if(v - par && has(t[u], v)) {
        int x = move(v); 
        if(x) X |= 1 << num[v]; 
        dfs(v, u); 
    } if(par + 1) move(par); 
}

long long Ioi(int N, int M, int A[], int B[], int P, int V, int T) {
    for(int i = 0; i < M; i++) {
        g[A[i]].push_back(B[i]); 
        g[B[i]].push_back(A[i]); 
    } gen(0);
    memset(num, -1, sizeof num);
    dfs(0, -1); 
    sort(q.begin(), q.end());
    for(int u : q) t[u] = q; 
    for(int i = 0; i < q.size(); i++) {
       int u = q[i]; 
       for(int v : adj[u]) if(num[v] == -1) {
           vector<int> T = t[u]; 
           for(int w : T) {
               int x = p[w]; 
               if(x != -1 && has(T, x)) 
                   d[w]++, d[x]++; 
           }
           int x = -1; 
           for(int w : T) if(w != u && d[w] == 1) x = w; 
           num[v] = num[x]; 
           for(int w : T) if(w != x) t[v].push_back(w);
           t[v].push_back(v); 
           p[v] = u; 
           q.push_back(v); 
           for(int w : T) d[w] = 0;
           sort(t[v].begin(), t[v].end()); 
        }
    }
    
    if(V) X = 1 << num[P]; 
    solve(P, -1); 
    return X; 
}

Compilation message

Joi.cpp: In function 'long long int Ioi(int, int, int*, int*, int, int, int)':
Joi.cpp:47:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0; i < q.size(); i++) {
                    ~~^~~~~~~~~~
/tmp/ccByHHXw.o: In function `main':
grader_joi.cpp:(.text.startup+0x1ac): undefined reference to `Joi(int, int, int*, int*, long long, int)'
collect2: error: ld returned 1 exit status

Ioi.cpp: In function 'long long int Ioi(int, int, int*, int*, int, int, int)':
Ioi.cpp:47:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0; i < q.size(); i++) {
                    ~~^~~~~~~~~~