답안 #864435

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
864435 2023-10-22T21:22:20 Z Ahmed57 CEOI16_icc (CEOI16_icc) C++17
40 / 100
123 ms 3152 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();
    }
}
int quer(int a,int b,vector<int>A , vector<int> B){
    int AA[a];
    for(int i = 0;i<A.size();i++)AA[i] = A[i];
    int BB[b];
    for(int i = 0;i<B.size();i++)BB[i] = B[i];
    return query(a,b,AA,BB);
}
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++){
            vector<int> lol;
            vector<int> fi , se;
            for(int i = 1;i<=n;i++){
                if(i==find(i))lol.push_back(i);
            }
            shuffle(lol.begin(),lol.end(),rng);
            for(int i = 0;i<(n-it)/2;i++)for(auto a3:v[lol[i]])fi.push_back(a3);
            for(int i = (n-it)/2;i<n-it;i++)for(auto a3:v[lol[i]])se.push_back(a3);
            if(quer(fi.size(),se.size(),fi,se)){
                a = fi , b = se;
                break;
            }
        }
        while(a.size()>1||b.size()>1){
            if(a.size()<b.size())swap(a,b);
            vector<int> A,B;
            for(int i = 0;i<a.size();i++){
                A.push_back(a[i]);
            }for(int i = 0;i<max(int(b.size()/2),1);i++){
                B.push_back(b[i]);
            }
            if(quer(A.size(),B.size(),A,B)){
                A.clear();
                for(int i = 0;i<max(int(a.size()/2),1);i++){
                    A.push_back(a[i]);
                }
                if(quer(A.size(),B.size(),A,B)){
                    a = A , b = B;
                    continue;
                }else{
                    A.clear();
                    for(int i = a.size()/2;i<a.size();i++){
                        A.push_back(a[i]);
                    }
                    a = A;b = B;
                    continue;
                }
                continue;
            }else{
                B.clear();
                for(int i = b.size()/2;i<b.size();i++){
                    B.push_back(b[i]);
                }
                A.clear();
                for(int i = 0;i<max(int(a.size()/2),1);i++){
                    A.push_back(a[i]);
                }
                if(quer(A.size(),B.size(),A,B)){
                    a = A , b = B;
                    continue;
                }else{
                    A.clear();
                    for(int i = a.size()/2;i<a.size();i++){
                        A.push_back(a[i]);
                    }
                    a = A;b = B;
                    continue;
                }
                continue;
            }
        }
        setRoad(a[0],b[0]);
        merge(a[0],b[0]);
    }
}
/*int main(){

}*/

Compilation message

icc.cpp: In function 'int quer(int, int, std::vector<int>, std::vector<int>)':
icc.cpp:27:20: 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 = 0;i<A.size();i++)AA[i] = A[i];
      |                   ~^~~~~~~~~
icc.cpp:29:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |     for(int i = 0;i<B.size();i++)BB[i] = B[i];
      |                   ~^~~~~~~~~
icc.cpp: In function 'void run(int)':
icc.cpp:58:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   58 |             for(int i = 0;i<a.size();i++){
      |                           ~^~~~~~~~~
icc.cpp:73:45: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   73 |                     for(int i = a.size()/2;i<a.size();i++){
      |                                            ~^~~~~~~~~
icc.cpp:82:41: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   82 |                 for(int i = b.size()/2;i<b.size();i++){
      |                                        ~^~~~~~~~~
icc.cpp:94:45: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   94 |                     for(int i = a.size()/2;i<a.size();i++){
      |                                            ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 2908 KB Ok! 109 queries used.
2 Correct 5 ms 2908 KB Ok! 126 queries used.
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 2904 KB Ok! 619 queries used.
2 Correct 39 ms 2980 KB Ok! 893 queries used.
3 Correct 39 ms 2908 KB Ok! 873 queries used.
# 결과 실행 시간 메모리 Grader output
1 Correct 88 ms 2908 KB Ok! 1700 queries used.
2 Correct 123 ms 2972 KB Ok! 2168 queries used.
3 Correct 98 ms 2908 KB Ok! 1952 queries used.
4 Correct 101 ms 3152 KB Ok! 1926 queries used.
# 결과 실행 시간 메모리 Grader output
1 Correct 93 ms 2984 KB Ok! 1832 queries used.
2 Correct 95 ms 3104 KB Ok! 1843 queries used.
3 Incorrect 103 ms 2984 KB Too many queries! 2017 out of 2000
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 104 ms 2984 KB Too many queries! 1994 out of 1775
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 112 ms 2984 KB Too many queries! 2024 out of 1625
2 Halted 0 ms 0 KB -