Submission #963657

# Submission time Handle Problem Language Result Execution time Memory
963657 2024-04-15T12:30:39 Z LucaIlie ICC (CEOI16_icc) C++17
Compilation error
0 ms 0 KB
#include "icc.h"
#include <bits/stdc++.h>

using namespace std;

const int MAX_N = 100;
int leader[MAX_N + 1];
vector<int> group[MAX_N + 1];

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

pair<int, int> solve( vector<int> a, vector<int> b ) {
    if ( b.size() == 1 ) {
        if ( a.size() == 1 )
            return { a[0], b[0] };

        vector<int> a1, a2;
        for ( int i = 0; i < a.size() / 2; i++ )
            a1.push_back( a[i] );
        for ( int i = a.size() / 2; i < a.size(); i++ )
            a2.push_back( a[i] );

        if ( qry( a1, b ) )
            return solve( a1, b );
        return solve( a2, b );
    }

    vector<int> b1, b2;
    for ( int i = 0; i < b.size() / 2; i++ )
        b1.push_back( b[i] );
    for ( int i = b.size() / 2; i < b.size(); i++ )
        b2.push_back( b[i] );

    if ( qry( a, b1 ) )
        return solve( a, b1 );
    return solve( a, b2 );
}

void run( int n ) {
    for ( int v = 1; v <= n; v++ ) {
        leader[v] = v;
        group[v].push_back( v );
    }
    for ( int i = 0; i < n - 1; i++ ) {
        vector<vector<int>> g;
        for ( int v = 1; v <= n; v++ ) {
            if ( leader[v] == v )
                g.push_back( group[v] );
        }

        int s = 0;
        while ( 1 ) {
            unsigned seed = chrono::system_clock::now().time_since_epoch().count();
            shuffle( g.begin(), g.end(), default_random_engine( seed ) );

            int x = g.size() / 3 + rand() % (g.size() / 3);
            x = max( g.size() - 1, x );
            
            vector<int> a, b;
            for ( int i = 0; i < x; i++ ) {
                for ( int v: g[i] )
                    a.push_back( v );
            }
            for ( int i = x; i < g.size(); i++ ) {
                for ( int v: g[i] )
                    b.push_back( v );
            }
            s++;

            /*for ( int i = 0; i < a.size(); i++ )
                cout << a[i] << " ";
            cout << "\n";
            for ( int i = 0; i < b.size(); i++ )
                cout << b[i] << " ";
            cout << "\n";
            cout << "\n";*/

            if ( qry( a, b ) ) {
                auto e = solve( a, b );
                setRoad( e.first, e.second );
                int x = leader[e.first], y = leader[e.second];
                for ( int v: group[y] ) {
                    leader[v] = x;
                    group[x].push_back( v );
                }
                group[y].clear();
                break;
            }
        }
    }
}

Compilation message

icc.cpp: In function 'bool qry(std::vector<int>, std::vector<int>)':
icc.cpp:12:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |     for ( int i = 0; i < a.size(); i++ )
      |                      ~~^~~~~~~~~~
icc.cpp:14:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |     for ( int i = 0; i < b.size(); i++ )
      |                      ~~^~~~~~~~~~
icc.cpp: In function 'std::pair<int, int> solve(std::vector<int>, std::vector<int>)':
icc.cpp:25:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |         for ( int i = 0; i < a.size() / 2; i++ )
      |                          ~~^~~~~~~~~~~~~~
icc.cpp:27:39: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |         for ( int i = a.size() / 2; i < a.size(); i++ )
      |                                     ~~^~~~~~~~~~
icc.cpp:36:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |     for ( int i = 0; i < b.size() / 2; i++ )
      |                      ~~^~~~~~~~~~~~~~
icc.cpp:38:35: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |     for ( int i = b.size() / 2; i < b.size(); i++ )
      |                                 ~~^~~~~~~~~~
icc.cpp: In function 'void run(int)':
icc.cpp:64:38: error: no matching function for call to 'max(std::vector<std::vector<int> >::size_type, int&)'
   64 |             x = max( g.size() - 1, x );
      |                                      ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from icc.cpp:2:
/usr/include/c++/10/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
icc.cpp:64:38: note:   deduced conflicting types for parameter 'const _Tp' ('long unsigned int' and 'int')
   64 |             x = max( g.size() - 1, x );
      |                                      ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from icc.cpp:2:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
icc.cpp:64:38: note:   deduced conflicting types for parameter 'const _Tp' ('long unsigned int' and 'int')
   64 |             x = max( g.size() - 1, x );
      |                                      ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from icc.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3480:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3480 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3480:5: note:   template argument deduction/substitution failed:
icc.cpp:64:38: note:   mismatched types 'std::initializer_list<_Tp>' and 'long unsigned int'
   64 |             x = max( g.size() - 1, x );
      |                                      ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from icc.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3486:5: note:   template argument deduction/substitution failed:
icc.cpp:64:38: note:   mismatched types 'std::initializer_list<_Tp>' and 'long unsigned int'
   64 |             x = max( g.size() - 1, x );
      |                                      ^
icc.cpp:71:32: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   71 |             for ( int i = x; i < g.size(); i++ ) {
      |                              ~~^~~~~~~~~~