답안 #52018

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
52018 2018-06-23T09:12:50 Z someone_aa CEOI16_icc (CEOI16_icc) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#include "icc.h"
using namespace std;

const int maxn = 110;
int parent[maxn];

vector<int>comps[maxn];

int uroot(int x) {
    while(x != parent[x]) x = parent[x];
    return x;
}

void unite(int x, int y) {
    x = uroot(x);
    y = uroot(y);

    if(x==y) return;
    for(int i:comps[x]) {
        comps[y].push_back(i);
    }
    parent[x] = y;
}

bool qq(set<int>a, set<int> b) {
    int aa[a.size()], bb[b.size()];
    int br = 0;
    for(int i:a) aa[br++] = i;
    br = 0;
    for(int i:b) bb[br++] = i;
    return query(a.size(), b.size(), aa, bb);
}

int bin(set<int>a, set<int>b) {
    if(b.size() == 1) return *(b.begin());

    set<int>fi, si;
    int br = 0;

    for(int i:b) {
        if(br < (b.size()/2)) {
            fi.insert(i); br++;
        }
        else si.insert(i);
    }

    if(qq(a, fi)) bin(a, fi);
    else bin(a, si);
}

void run(int n) {
    set<int>c;

    for(int i=1;i<=n;i++) {
        parent[i] = i;
        comps[i].push_back(i);
    }

    for(int edges=1;edges<n;edges++) {
        for(int i=1;i<=n;i++) {
            c.insert(uroot(i));
        }

        for(int i=0;i<=7;i++) {
            set<int>a, b;
            for(int j:c) {
                if(j&(1<<i)) for(int k:comps[j]) a.insert(k);
                else for(int k:comps[j]) b.insert(k);
            }

            if(qq(a, b)) {
                int x = bin(a, b);
                int y = bin(b, a);
                setRoad(x, y);
                unite(x, y);
                break;
            }
        }
    }
}

int main() {
    run(4);
    return 0;
}

Compilation message

icc.cpp: In function 'int bin(std::set<int>, std::set<int>)':
icc.cpp:42:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if(br < (b.size()/2)) {
            ~~~^~~~~~~~~~~~~~
icc.cpp:50:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
/tmp/cclioC9f.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/cc0BCooR.o:icc.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status