답안 #42950

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
42950 2018-03-06T19:52:51 Z MatheusLealV Simurgh (IOI17_simurgh) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#include "simurgh.h"
using namespace std;

int n, m;

int ok[N], pai[N];

vector<int> grafo[N];

int Find(int x)
{
    if(x == pai[x]) return x;

    return pai[x] = Find(pai[x]);
}

void join(int a, int b)
{
    a = Find(a), b = Find(b);

    if(a == b) return;

    pai[a] = b;
}

bool check(vector<int> vet, vector<int> &u, vector<int> &v)
{
    if(vet.size() != n - 1) return false;

    for(int i = 0; i < n; i++) pai[i] = i;

    for(auto x: vet)
    {
        join(u[x], v[x]);
    }

    set<int> ss;

    for(int i = 0; i < n; i++) ss.insert(Find(i));

    if(ss.size() != 1) return false;

    if(count_common_roads(vet) == n - 1) return true;

    else return false;
}

vector<int> find_roads(int n_, vector<int> u, vector<int> v)
{
    n = n_;

    m = u.size();

    for(int i = 0; i < m; i++) grafo[u[i]].push_back(v[i]), grafo[v[i]].push_back(u[i]);

    for(int mask = 0; mask < (1<<m); mask ++)
    {
        vector<int> aux;

        for(int i = 0; i < m; i++)
        {
            if(mask & (1<<i))
            {
                aux.push_back(i);
            }
        }

        if(check(aux, u, v)) return aux;
    }

    return u;
}

Compilation message

simurgh.cpp:7:8: error: 'N' was not declared in this scope
 int ok[N], pai[N];
        ^
simurgh.cpp:7:16: error: 'N' was not declared in this scope
 int ok[N], pai[N];
                ^
simurgh.cpp:9:19: error: 'N' was not declared in this scope
 vector<int> grafo[N];
                   ^
simurgh.cpp: In function 'int Find(int)':
simurgh.cpp:13:13: error: 'pai' was not declared in this scope
     if(x == pai[x]) return x;
             ^
simurgh.cpp:15:12: error: 'pai' was not declared in this scope
     return pai[x] = Find(pai[x]);
            ^
simurgh.cpp: In function 'void join(int, int)':
simurgh.cpp:24:5: error: 'pai' was not declared in this scope
     pai[a] = b;
     ^
simurgh.cpp: In function 'bool check(std::vector<int>, std::vector<int>&, std::vector<int>&)':
simurgh.cpp:29:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     if(vet.size() != n - 1) return false;
                   ^
simurgh.cpp:31:32: error: 'pai' was not declared in this scope
     for(int i = 0; i < n; i++) pai[i] = i;
                                ^
simurgh.cpp: In function 'std::vector<int> find_roads(int, std::vector<int>, std::vector<int>)':
simurgh.cpp:55:32: error: 'grafo' was not declared in this scope
     for(int i = 0; i < m; i++) grafo[u[i]].push_back(v[i]), grafo[v[i]].push_back(u[i]);
                                ^