Submission #532078

# Submission time Handle Problem Language Result Execution time Memory
532078 2022-03-02T05:17:11 Z gg123_pe ICC (CEOI16_icc) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include "icc.h"
using namespace std; 

typedef pair<int,int> ii; 
#define f(i,a,b) for(int i = a; i < b; i++)
#define ff first 
#define ss second 

int n, p[105]; 
vector <int> adj[105], parents; 

void divide(vector <ii> v1, vector <ii> v2, vector <ii> &a1, vector <ii> &a2){
    for(auto p: v1){
        int l = p.ff, r = p.ss, sz = r-l+1; 
        if(sz > 1) a1.push_back({l, l+sz/2-1}), a2.push_back({l+sz/2, r}); 
        else a1.push_back({l, r}); 
    }
    for(auto p: v2){
        int l = p.ff, r = p.ss, sz = r-l+1; 
        if(sz > 1) a1.push_back({l, l+sz/2-1}), a2.push_back({l+sz/2, r}); 
        else a1.push_back({l, r}); 
    }
}

vector <int> get(vector <ii> v){
    vector <int> ra; 
    for(auto p: v){
        int l = p.ff, r = p.ss; 
        f(i,l,r+1) for(int x: adj[parents[i]]) ra.push_back(x);
    }
    return ra; 
}
void run(int x){ 
    n = x; 
    f(i,1,n+1) adj[i] = {i}, p[i] = i; 

    f(ra,1,n){
        parents.clear(); vector <ii> v1, v2;  vector <int> V1, V2; 
        f(i,1,n+1) if(adj[i].size()) parents.push_back(i); 

        int sz = parents.size(); 
        v1 = {0, sz-1}; 
        while(1){
            vector <ii> aux1, aux2; 
            divide(v1, v2, aux1, aux2);
            v1 = aux1, v2 = aux2; 
            V1 = get(v1), V2 = get(v2); 
            if(query(V1.size(), V2.size(), V1, V2)) break;
        }
        while(V1.size() > 1){
            int s = V1.size();
            vector <int> ra, ta; 
            f(i,0,s/2) ra.push_back(V1[i]); f(i,s/2,s) ta.push_back(V1[i]);

            if(query(V2.size(), ra.size(), V2, ra)) V1 = ra; 
            else V1 = ta; 
        }
        while(V2.size() > 1){
            int s = V2.size();
            vector <int> ra, ta; 
            f(i,0,s/2) ra.push_back(V2[i]); f(i,s/2,s) ta.push_back(V2[i]);

            if(query(V1.size(), ra.size(), V1, ra)) V2 = ra; 
            else V2 = ta; 
        }
        int x = V1[0], y = V2[0];
        x = p[x], y = p[y]; 
        setRoad(x, y);
        for(int wi: adj[x]) p[wi] = y, adj[y].push_back(wi);
        adj[x].clear();  
    }
}

Compilation message

icc.cpp: In function 'void run(int)':
icc.cpp:43:22: error: no match for 'operator=' (operand types are 'std::vector<std::pair<int, int> >' and '<brace-enclosed initializer list>')
   43 |         v1 = {0, sz-1};
      |                      ^
In file included from /usr/include/c++/10/vector:72,
                 from /usr/include/c++/10/functional:62,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from icc.cpp:1:
/usr/include/c++/10/bits/vector.tcc:198:5: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >]'
  198 |     vector<_Tp, _Alloc>::
      |     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/bits/vector.tcc:199:42: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const std::vector<std::pair<int, int> >&'
  199 |     operator=(const vector<_Tp, _Alloc>& __x)
      |               ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/functional:62,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from icc.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:709:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >]'
  709 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:709:26: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<std::pair<int, int> >&&'
  709 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |                 ~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:730:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >]'
  730 |       operator=(initializer_list<value_type> __l)
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:730:46: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::initializer_list<std::pair<int, int> >'
  730 |       operator=(initializer_list<value_type> __l)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
icc.cpp:49:44: error: cannot convert 'std::vector<int>' to 'int*'
   49 |             if(query(V1.size(), V2.size(), V1, V2)) break;
      |                                            ^~
      |                                            |
      |                                            std::vector<int>
In file included from icc.cpp:2:
icc.h:10:30: note:   initializing argument 3 of 'int query(int, int, int*, int*)'
   10 | int query(int a, int b, int *A, int *B);
      |                         ~~~~~^
icc.cpp:56:44: error: cannot convert 'std::vector<int>' to 'int*'
   56 |             if(query(V2.size(), ra.size(), V2, ra)) V1 = ra;
      |                                            ^~
      |                                            |
      |                                            std::vector<int>
In file included from icc.cpp:2:
icc.h:10:30: note:   initializing argument 3 of 'int query(int, int, int*, int*)'
   10 | int query(int a, int b, int *A, int *B);
      |                         ~~~~~^
icc.cpp:64:44: error: cannot convert 'std::vector<int>' to 'int*'
   64 |             if(query(V1.size(), ra.size(), V1, ra)) V2 = ra;
      |                                            ^~
      |                                            |
      |                                            std::vector<int>
In file included from icc.cpp:2:
icc.h:10:30: note:   initializing argument 3 of 'int query(int, int, int*, int*)'
   10 | int query(int a, int b, int *A, int *B);
      |                         ~~~~~^