Submission #565883

# Submission time Handle Problem Language Result Execution time Memory
565883 2022-05-21T13:40:12 Z Deepesson ICC (CEOI16_icc) C++17
0 / 100
232 ms 492 KB
#include <bits/stdc++.h>

#include "icc.h"

#define MAX 105

int query(int size_a, int size_b, int a[], int b[]);

int query(std::vector<int> a,std::vector<int> b){
    for(auto&x:a)++x;
    for(auto&x:b)++x;
    return query(a.size(),b.size(),a.data(),b.data());
}

void setRoad(int a, int b);
void InformaRua(int a,int b){setRoad(a+1,b+1);}
int pai[MAX];

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

void Union(int a,int b){
    a=find(a);
    b=find(b);
    pai[a]=b;
}

std::vector<std::vector<int>> gerar_grupos(int N){
    std::map<int,std::vector<int>> mapa;
    for(int i=0;i!=N;++i){
        mapa[find(i)].push_back(i);
    }
    std::vector<std::vector<int>> res;
    for(auto&x:mapa){
        res.push_back(x.second);
    }
    return res;
}

int splits[20];

int andar[MAX];
void dnc(int l,int r,int nv){
    if(l==r)return;
    int m = (l+r)/2;
    for(int i=l;i<=m;++i)andar[i]+=(1<<nv);
    dnc(l,m,nv+1);
    dnc(m+1,r,nv+1);
}

void add(std::vector<int>& ref,std::vector<int> cp){
    for(auto&x:cp)ref.push_back(x);
}

void pruning(std::vector<int>& a,std::vector<int> b){
    while(a.size()!=1){
        int m = a.size()/2;
        std::vector<int> c,d;
        for(int i=0;i<=m;++i){
            c.push_back(a[i]);
        }
        for(int i=m+1;i!=a.size();++i){
            d.push_back(a[i]);
        }
        if(query(c,b)){
            a=c;
        }else a=d;
    }
}
void run(int N) {
    for(int i=0;i!=MAX;++i)pai[i]=i;

    for(int i=1;i!=N;++i){
        auto grups = gerar_grupos(N);
        memset(andar,0,sizeof(andar));
        dnc(0,grups.size()-1,0);
        std::vector<int> l,r;
        for(int j=0;j!=20;++j){
            std::vector<int> a,b;
            for(int k=0;k!=grups.size();++k){
                if(!(andar[k]&(1<<j))){
                    add(a,grups[k]);
                }else add(b,grups[k]);
            }
            if(query(a,b)){
                l=a;
                r=b;
                goto prox;
            }
        }
        prox:
        pruning(l,r);
        pruning(r,l);
        assert(r.size()==1);
        assert(l.size()==1);
        InformaRua(l[0],r[0]);
        Union(l[0],r[0]);
    }
}

Compilation message

icc.cpp: In function 'void pruning(std::vector<int>&, std::vector<int>)':
icc.cpp:66:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   66 |         for(int i=m+1;i!=a.size();++i){
      |                       ~^~~~~~~~~~
icc.cpp: In function 'void run(int)':
icc.cpp:84:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   84 |             for(int k=0;k!=grups.size();++k){
      |                         ~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 122 ms 472 KB Number of queries more than 3000 out of 1500
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 232 ms 484 KB Number of queries more than 5000 out of 2500
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 231 ms 488 KB Number of queries more than 4500 out of 2250
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 217 ms 492 KB Number of queries more than 4000 out of 2000
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 176 ms 488 KB Number of queries more than 3550 out of 1775
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 154 ms 468 KB Number of queries more than 3250 out of 1625
2 Halted 0 ms 0 KB -