Submission #117638

# Submission time Handle Problem Language Result Execution time Memory
117638 2019-06-17T02:41:23 Z minhtung0404 ICC (CEOI16_icc) C++17
0 / 100
411 ms 632 KB
//https://oj.uz/problem/view/CEOI16_icc

#include<bits/stdc++.h>
#include "icc.h"
const int N = 105;
using namespace std;

vector <int> mv[N];
int pset[N], cnt = 0;

int find(int i) {return ((pset[i] == i) ? i : pset[i] = find(pset[i]));}

void dsu(int i, int j){
    i = find(i); j = find(j);
    if (i == j) return;
    if (mv[i].size() > mv[j].size()) swap(i, j);
    for (auto x : mv[i]) mv[j].push_back(x);
    pset[i] = j;
}

bool query(vector <int> &a, vector <int> &b){
    int A[N], B[N], siza = a.size(), sizb = b.size();
    for (int i = 0; i < siza; i++) A[i] = a[i];
    for (int i = 0; i < sizb; i++) B[i] = b[i];
    return query(siza, sizb, A, B);
}

void find(vector <int>&a, vector <int>& b){
    if (a.size() == 1) return;
    int siz = (int)a.size() / 2;
    vector <int> x; x.clear();
    for (int i = 0; i < siz; i++) x.push_back(a[i]);
    cnt++;
    if (!query(x, b)){
        x.clear();
        for (int i = siz; i < (int)a.size(); i++) x.push_back(a[i]);
    }
    a.swap(x);
    find(a, b);
}

void cal(vector <int>& a, vector <int>& b){
    cnt = 0; find(a, b);
    cnt = 0; find(b, a);
    setRoad(a[0], b[0]); dsu(a[0], b[0]);
}

void run(int n){
    for (int i = 1; i <= n; i++) pset[i] = i, mv[i].push_back(i);
    while (1){
        vector <int> A;
        for (int i = 1; i <= n; i++) if (pset[i] == i) A.push_back(i);
        for (int i = 0; (1 << i) < (int)A.size(); i++){
            vector <int> a, b;
            for (int j = 0; j < (int)A.size(); j++){
                if ((j >> i)&1){
                    for (auto x : mv[j]) a.push_back(x);
                }
                else{
                    for (auto x : mv[j]) b.push_back(x);
                }
            }
            if (query(a, b)){
                cal(a, b); break;
            }
        }
    }
}
# Verdict Execution time Memory Grader output
1 Incorrect 165 ms 632 KB Number of queries more than 3000 out of 1500
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 512 KB The query sets must be disjoint
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 411 ms 568 KB Number of queries more than 4500 out of 2250
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 393 ms 564 KB Number of queries more than 4000 out of 2000
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 334 ms 632 KB Number of queries more than 3550 out of 1775
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 302 ms 560 KB Number of queries more than 3250 out of 1625
2 Halted 0 ms 0 KB -