Submission #1116992

# Submission time Handle Problem Language Result Execution time Memory
1116992 2024-11-22T17:55:56 Z hyakup ICC (CEOI16_icc) C++17
Compilation error
0 ms 0 KB
#include "icc.h"
#include <bits/stdc++.h>
using namespace std;
#define bug(x) cout << #x << " "  << x << endl;

const int maxn = 110;
const int logn = 8;

vector<int> pai( maxn ), componente[maxn];

int find( int a ){ return (( pai[a] == a ) ? a : pai[a] = find(pai[a]) ); }
void join( int a, int b ){
    a = find(a); b = find(b);
    if( a == b ) return;
    for( int x : componente[b] ) componente[a].push_back(x);
    pai[b] = a;
}

int get_node( vector<int>& va, vector<int>& vb ){
    int a[(int)va.size()], b[(int)vb.size()], pa = 0, pb = 0;
    for( int i = 0; i < va.size(); i++ ) a[pa++] = va[i];
    int l = 0, r = (int)vb.size() - 1;
    while( l < r ){
        int mid = ( l + r )/2;
        pb = 0;
        for( int i = l; i <= mid; i++ ) b[pb++] = vb[i];
        if( query( pa, pb, a, b ) ) r = mid;
        else l = mid + 1;
    }
    return vb[r];
}

int a[maxn], b[maxn];

void run( int n ){
    for( int i = 1; i <= n; i++ ){ pai[i] = i; componente[i].push_back(i); }
    for( int i = 1; i < n; i++ ){
        int pa = 0, pb = 0;
        for( int k = 0; k < logn; k++ ){
            pa = 0, pb = 0;
            for( int cur = 1; cur <= n; cur++ ) if( pai[cur] == cur ){
                for( int x : componente[cur] ){
                    if( (cur&(1<<k)) > 0 ) a[pa++] = x;
                    else b[pb++] = x;
                }
            }

            if( query( pa, pb, a, b ) ) break;
        }
        vector<int> va(pa), vb(pb);
        for( int i = 0; i < pa; i++ ) va[i] = a[i];
        for( int i = 0; i < pb; i++ ) vb[i] = b[i];

        int x = get_node( va, vb ), y = get_node( vb, va );
        setRoad( x, y );
        join( x, y ); 
    }
}

int main(){ /////// para testar
    int n; cin >> n;
    run( n );
}

Compilation message

icc.cpp: In function 'int get_node(std::vector<int>&, std::vector<int>&)':
icc.cpp:21:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |     for( int i = 0; i < va.size(); i++ ) a[pa++] = va[i];
      |                     ~~^~~~~~~~~~~
/usr/bin/ld: /tmp/ccDoqO3X.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccRlE1KZ.o:icc.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status