답안 #864420

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
864420 2023-10-22T20:03:41 Z Ahmed57 CEOI16_icc (CEOI16_icc) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#include "icc.h"

int p[100001];
vector<int> v[100001];
int find(int x){
    if(x==p[x])return x;
    return p[x] = find(p[x]);
}
void merge(int a,int b){
    a = find(a) , b = find(b);
    if(a==b)return ;
    if(v[a].size()<v[b].size())swap(a,b);
    p[b] = a;
    while(v[b].size()){
        v[a].push_back(v[b].back());v[b].pop_back();
    }
}
mt19937 rng;
void run(int n){
    rng.seed(time(0));
    for(int i = 1;i<=n;i++){
        p[i] = i;
        v[i].push_back(i);
    }
    for(int it = 0;it<n-1;it++){
        vector<int> a , b;
        for(int xd = 0;;xd++){
            ordered_set lol;
            vector<int> fi , se;
            for(int i = 1;i<=n;i++){
                if(i==find(i))lol.insert(i);
            }
            for(int i = 0;i<(n-it)/2;i++){
                int x = rng()%lol.size();
                auto it = lol.find_by_order(x);
                for(auto a3:v[(*it)])fi.push_back(a3);
                lol.erase(it);
            }
            for(auto i:lol){
                for(auto a3:v[i])se.push_back(a3);
            }
            if(query(fi.size(),se.size(),fi,se)){
                a = fi , b = se;
                break;
            }
        }
        while(a.size()>1||b.size()>1){
            {//first half with first half
                vector<int> A,B;
                for(int i = 0;i<max(int(a.size()/2),1);i++){
                    A.push_back(a[i]);
                }for(int i = 0;i<max(int(b.size()/2),1);i++){
                    A.push_back(b[i]);
                }
                if(query(A.size(),B.size(),A,B)){
                    a = A, b = B;
                    continue;
                }
            }
            {//second half with first half
                vector<int> A,B;
                for(int i = a.size()/2;i<a.size();i++){
                    A.push_back(a[i]);
                }for(int i = 0;i<max(int(b.size()/2),1);i++){
                    A.push_back(b[i]);
                }
                if(query(A.size(),B.size(),A,B)){
                    a = A, b = B;
                    continue;
                }
            }
            {//first half with second half
                vector<int> A,B;
                for(int i = 0;i<max(int(a.size()/2),1);i++){
                    A.push_back(a[i]);
                }for(int i = b.size()/2;i<b.size();i++){
                    A.push_back(b[i]);
                }
                if(query(A.size(),B.size(),A,B)){
                    a = A, b = B;
                    continue;
                }
            }
            {//second half with second half
                vector<int> A,B;
                for(int i = a.size()/2;i<a.size();i++){
                    A.push_back(a[i]);
                }for(int i = b.size()/2;i<b.size();i++){
                    A.push_back(b[i]);
                }
                a = A, b = B;
                continue;
            }
        }
        setRoad(a[0],b[0]);
        merge(a[0],b[0]);
    }
}
/*int main(){

}*/

Compilation message

icc.cpp: In function 'void run(int)':
icc.cpp:49:42: error: cannot convert 'std::vector<int>' to 'int*'
   49 |             if(query(fi.size(),se.size(),fi,se)){
      |                                          ^~
      |                                          |
      |                                          std::vector<int>
In file included from icc.cpp:8:
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:62:44: error: cannot convert 'std::vector<int>' to 'int*'
   62 |                 if(query(A.size(),B.size(),A,B)){
      |                                            ^
      |                                            |
      |                                            std::vector<int>
In file included from icc.cpp:8:
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:69:41: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   69 |                 for(int i = a.size()/2;i<a.size();i++){
      |                                        ~^~~~~~~~~
icc.cpp:74:44: error: cannot convert 'std::vector<int>' to 'int*'
   74 |                 if(query(A.size(),B.size(),A,B)){
      |                                            ^
      |                                            |
      |                                            std::vector<int>
In file included from icc.cpp:8:
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:83:42: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   83 |                 }for(int i = b.size()/2;i<b.size();i++){
      |                                         ~^~~~~~~~~
icc.cpp:86:44: error: cannot convert 'std::vector<int>' to 'int*'
   86 |                 if(query(A.size(),B.size(),A,B)){
      |                                            ^
      |                                            |
      |                                            std::vector<int>
In file included from icc.cpp:8:
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:93:41: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   93 |                 for(int i = a.size()/2;i<a.size();i++){
      |                                        ~^~~~~~~~~
icc.cpp:95:42: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   95 |                 }for(int i = b.size()/2;i<b.size();i++){
      |                                         ~^~~~~~~~~