답안 #707169

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
707169 2023-03-08T14:34:52 Z uylulu CEOI16_icc (CEOI16_icc) C++17
컴파일 오류
0 ms 0 KB
#include<bits/stdc++.h>
using namespace std;

#define endl "\n"

const int N = 100;

int a[N + 1],b[N + 1],pa[N + 1],n;

vector<int> st[N + 1];

int find(int a) {
    if(a == pa[a]) return a;
    return pa[a] = find(pa[a]);
}

void unite(int a,int b) {
    a = find(a);
    b = find(b);
    if(a == b) return;
    if(st[a].size() < st[b].size()) swap(a,b);

    pa[b] = a;
    for(auto u : st[b]) {
        st[a].push_back(u);
    }
}

int ask(vector<int> i1,vector<int> i2) {
    vector<int> l,r;

    for(auto u : i1) {
        for(auto v : st[u]) {
            l.push_back(v);
        }
    }
    for(auto u : i2) {
        for(auto v : st[u]) {
            r.push_back(v);
        }
    }
    for(int i = 0;i < l.size();i++) {
        a[i] = l[i];
    }
    for(int i = 0;i < r.size();i++) {
        b[i] = r[i];
    }
    return query((int)l.size(),(int)r.size(),a,b);
}

pair<int,int> cal(vector<int> le,vector<int> ri) {
    int l = 0,r = le.size(),trai = -1,phai = -1;
    vector<int> tmp;


    while(l < r) {
        int mid = (l + r)/2;
        tmp.clear();

        for(int i = l;i <= mid;i++) {
            tmp.push_back(le[i]);
        }
        if(ask(tmp,ri)) {
            trai = mid;
            r = mid;
        } else {
            l = mid + 1;
        }
    }

    l = 0;
    r = ri.size();

    while(l < r) {
        int mid = (l + r)/2;
        tmp.clear();

        for(int i = l;i <= mid;i++) {
            tmp.push_back(ri[i]);
        }
        if(ask(le,tmp)) {
            phai = mid;
            r = mid;
        } else {
            l = mid + 1;
        }
    }

    return {le[trai],ri[phai]};
}

void process() {
    vector<int> tl,tr;

    for(int pos = 0;pos < 7;pos++) {
        tl.clear();
        tr.clear();

        for(int i = 1;i <= n;i++) {
            if(i != find(i)) continue;

            if((i >> pos) % 2 == 0) {
                tl.push_back(i);
            } else {
                tr.push_back(i);
            }
        }

        if(ask(tl,tr)) {
            vector<int> i1,i2;

            for(auto u : tl) {
                for(auto v : st[u]) {
                    i1.push_back(v);
                }
            }
            for(auto u : tr) {
                for(auto v : st[u]) {
                    i2.push_back(v);
                }
            }
            auto res = cal(i1,i2);

            setRoad(res.first,res.second);
            unite(res.first,res.second);
            break;
        }
    }

}

void run(int N) {
    n = N;
    for(int i = 1;i <= n;i++) {
        pa[i] = i;
        st[i].push_back(i);
    }
    for(int i = 1;i < n;i++) {
        process();
    }
}    

Compilation message

icc.cpp: In function 'int ask(std::vector<int>, std::vector<int>)':
icc.cpp:42:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |     for(int i = 0;i < l.size();i++) {
      |                   ~~^~~~~~~~~~
icc.cpp:45:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |     for(int i = 0;i < r.size();i++) {
      |                   ~~^~~~~~~~~~
icc.cpp:48:12: error: 'query' was not declared in this scope
   48 |     return query((int)l.size(),(int)r.size(),a,b);
      |            ^~~~~
icc.cpp: In function 'void process()':
icc.cpp:124:13: error: 'setRoad' was not declared in this scope
  124 |             setRoad(res.first,res.second);
      |             ^~~~~~~