Submission #706970

# Submission time Handle Problem Language Result Execution time Memory
706970 2023-03-08T08:09:01 Z socpite ICC (CEOI16_icc) C++14
Compilation error
0 ms 0 KB
#include"icc.h"
#include<bits/stdc++.h>
using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define f first
#define s second

typedef long long ll;
typedef long double ld;

const int maxn = 105;
const int mod = 998244353;
 
int t, n;

map<int, int> mp;

/*int query(int sza, int szb, int a[], int b[]){
    cout << sza << endl;
    for(int i = 0; i < sza; i++)cout << a[i] << " ";
    cout << endl;
    cout << szb << endl;
    for(int i = 0; i < szb; i++)cout << b[i] << " ";
    cout << endl;
    int x;
    cin >> x;
    return x;
}

void setRoad(int a, int b){
    cout << "FOUND " << a << " " << b << endl;
}*/

int up[maxn];

int Find(int x){
    if(!up[x])return x;
    else return up[x] = Find(up[x]);
}

void Union(int a, int b){
    a = Find(a);
    b = Find(b);
    up[a] = b;
}

int arr1[maxn], arr2[maxn];

int gt(vector<int> a, vector<int> b){
    //cout << a.size() << " " << b.size() << "\n";
    if(a.empty() || b.empty())return 0;
    for(int i = 0; i < a.size(); i++)arr1[i] = a[i];
    for(int i = 0; i < b.size(); i++)arr2[i] = b[i];
    return query(a.size(), b.size(), arr1, arr2);
}

int bs(vector<int> a, vector<int> b){
    int l = 0, r = a.size()-1;
    shuffle(a.begin(), a.end());
    shuffle(b.begin(), b.end());
    while(l < r){
        int mid = (l+r+1)>>1;
        if(gt(vector<int>(a.begin(), a.begin()+mid), b))r = mid-1;
        else l = mid;
    }
    return a[l];
}

void findedge(vector<int> a, vector<int> b){
    assert(!a.empty() && !b.empty());
    int h1 = bs(a, b), h2 = bs(b, a);
    Union(h1, h2);
    setRoad(h1, h2);
}

void run(int N){
    n = N;
    for(int i = 0; i < n-1; i++){
        mp.clear();
        int crr = 0;
        vector<int> ord;
        for(int i = 1; i <= n; i++)ord.push_back(i);
        shuffle(ord.begin(), ord.end(), rng);
        for(auto i: ord)if(mp.find(Find(i)) == mp.end())mp[Find(i)] = crr++;
        ord.clear();
        for(int i = 0; i < 10; i++)ord.push_back(i);
        shuffle(ord.begin(), ord.end(), rng);
        for(auto j: ord){
            //cout << i << " " << j << endl;
            vector<int> v[2];
            for(int k = 1; k <= n; k++)v[(mp[Find(k)]>>j)&1].push_back(k);
            //cout << v[0].size() << " " << v[1].size() << endl;
            if(gt(v[0], v[1])){
                findedge(v[0], v[1]);
                break;
            }
        }
    }
}

Compilation message

icc.cpp: In function 'int gt(std::vector<int>, std::vector<int>)':
icc.cpp:54:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   54 |     for(int i = 0; i < a.size(); i++)arr1[i] = a[i];
      |                    ~~^~~~~~~~~~
icc.cpp:55:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |     for(int i = 0; i < b.size(); i++)arr2[i] = b[i];
      |                    ~~^~~~~~~~~~
icc.cpp: In function 'int bs(std::vector<int>, std::vector<int>)':
icc.cpp:61:31: error: no matching function for call to 'shuffle(std::vector<int>::iterator, std::vector<int>::iterator)'
   61 |     shuffle(a.begin(), a.end());
      |                               ^
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:3748:5: note: candidate: 'template<class _RAIter, class _UGenerator> void std::shuffle(_RAIter, _RAIter, _UGenerator&&)'
 3748 |     shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last,
      |     ^~~~~~~
/usr/include/c++/10/bits/stl_algo.h:3748:5: note:   template argument deduction/substitution failed:
icc.cpp:61:31: note:   candidate expects 3 arguments, 2 provided
   61 |     shuffle(a.begin(), a.end());
      |                               ^
icc.cpp:62:31: error: no matching function for call to 'shuffle(std::vector<int>::iterator, std::vector<int>::iterator)'
   62 |     shuffle(b.begin(), b.end());
      |                               ^
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:3748:5: note: candidate: 'template<class _RAIter, class _UGenerator> void std::shuffle(_RAIter, _RAIter, _UGenerator&&)'
 3748 |     shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last,
      |     ^~~~~~~
/usr/include/c++/10/bits/stl_algo.h:3748:5: note:   template argument deduction/substitution failed:
icc.cpp:62:31: note:   candidate expects 3 arguments, 2 provided
   62 |     shuffle(b.begin(), b.end());
      |                               ^