답안 #986292

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
986292 2024-05-20T09:11:55 Z AlphaMale06 CEOI16_icc (CEOI16_icc) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;

int query(int n, int m, int a[], int b[]);
void setRoad(int a, int b);

const int N = 101;

int p[N], sz[N];
vector<int> comp[N];

int find(int v){
    if(p[v]==v)return v;
    return p[v]=find(p[v]);
}

void merge(int v, int u){
    v=find(v);
    u=find(u);
    if(u==v)return;
    if(sz[u]<sz[v])swap(u, v);
    p[v]=u;
    sz[u]+=sz[v];
    for(int e : comp[v])comp[u].push_back(e);
}

void run(int n){
    for(int i=1; i<=n; i++){
        p[i]=i;
        sz[i]=1;
        comp[i].push_back(i);
    }
    for(int i=0; i< n-1; i++){
        set<int> st;
        for(int j=1; j<=n; j++)st.insert(find(j));
        vector<int> a;
        for(auto p : st)a.push_back(p);
        vector<int> st1, st2;
        for(int j=0; j<7; j++){
            for(int k=1; k<= n; k++){
                int x = k>>j;
                if(x&1){
                    for(int e : comp[k])st1.push_back(e);
                }
                else{
                    for(int e : comp[k])st2.push_back(e);
                }
            }
            int sz1=st1.size(), sz2=st2.size();
            int fst[sz1], scd[sz2];
            for(int i=0; i< sz1; i++)fst[i]=st1[i];
            for(int i=0; i< sz2; i++)scd[i]=st2[i];
            if(query(sz1, sz2, fst, scd))break;
            st1.clear(); st2.clear();
        }
        vector<int> nscd = st2;
        int sz1 = st1.size();
        int fst[sz1];
        for(int i=0; i< sz1; i++)fst[i]=st1[i];
        while(nscd.size()>1){
            int sz = nscd.size()/2;
            int scd[sz];
            for(int i=0; i< sz; i++)scd[i]=nscd[i];
            if(query(sz1, sz, fst, scd)){
                while(nscd.size()>sz)nscd.pop_back();
            }
            else{
                reverse(nscd.begin(), nscd.end());
                for(int i=0; i<sz; i++)nscd.pop_back();
                reverse(nscd.begin(), nscd.end());
            }
        }
        int scd[1] = {nscd[0]};
        vector<int> nfst = st1;
        while(nfst.size()>1){
            int sz=nfst.size()/2;
            int fst[sz];
            for(int i=0; i< sz; i++)fst[i]=nfst[i];
            if(query(sz, 1, fst, scd)){
                while(nfst.size()>sz)nfst.pop_back();
            }
            else{
                reverse(nfst.begin(), nfst.end());
                for(int i=0; i< sz; i++)nfst.pop_back();
                reverse(nfst.begin(), nfst.end());
            }
        }
        setRoad(nfst[0], nscd[0]);
        merge(nfst[0], nscd[0]);
    }
}

Compilation message

icc.cpp: In function 'void run(int)':
icc.cpp:65:34: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   65 |                 while(nscd.size()>sz)nscd.pop_back();
      |                       ~~~~~~~~~~~^~~
icc.cpp:80:34: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   80 |                 while(nfst.size()>sz)nfst.pop_back();
      |                       ~~~~~~~~~~~^~~
/usr/bin/ld: /tmp/ccIRggFr.o: in function `run(int)':
icc.cpp:(.text+0x9ef): undefined reference to `query(int, int, int*, int*)'
/usr/bin/ld: icc.cpp:(.text+0xc28): undefined reference to `query(int, int, int*, int*)'
/usr/bin/ld: icc.cpp:(.text+0xde2): undefined reference to `query(int, int, int*, int*)'
/usr/bin/ld: icc.cpp:(.text+0xe5b): undefined reference to `setRoad(int, int)'
/usr/bin/ld: /tmp/ccihvkXs.o: in function `main':
grader.cpp:(.text.startup+0x17): undefined reference to `run'
collect2: error: ld returned 1 exit status