Submission #116949

# Submission time Handle Problem Language Result Execution time Memory
116949 2019-06-14T08:16:45 Z minhtung0404 ICC (CEOI16_icc) C++17
0 / 100
5 ms 384 KB
//https://oj.uz/problem/view/CEOI16_icc

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

int pset[N];

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;
    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 && b.size() == 1) return;
    if (a.size() == 1 && b.size() != 1){
        find(b, a);
        return;
    }
    int siz = (int)a.size() / 2;
    vector <int> x;
    for (int i = 0; i < siz; i++) x.push_back(a[i]);
    if (query(x, b)){
        a = x;
    }
    else{
        x.clear();
        for (int i = siz; i < a.size(); i++) x.push_back(a[i]);
        a = x;
        find(a, b);
    }
}

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

void run(int n){
    while (1){
        vector <int> A;
        for (int i = 1; i <= n; i++) if (pset[i] == i) A.push_back(i);
        for (int i = 1; (1 << i) <= n; i++){
            vector <int> a, b;
            for (auto j : A){
                if ((j >> i)&1){
                    a.push_back(j);
                }
                else{
                    b.push_back(j);
                }
            }
            if (query(a, b)){
                cal(a, b); break;
            }
        }
    }
}

Compilation message

icc.cpp: In function 'void find(std::vector<int>&, std::vector<int>&)':
icc.cpp:39:29: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int i = siz; i < a.size(); i++) x.push_back(a[i]);
                           ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 384 KB Number of queries more than 3000 out of 1500
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 384 KB Number of queries more than 5000 out of 2500
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB Number of queries more than 4500 out of 2250
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 384 KB Number of queries more than 4000 out of 2000
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 384 KB Number of queries more than 3550 out of 1775
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 384 KB Number of queries more than 3250 out of 1625
2 Halted 0 ms 0 KB -