Submission #688513

# Submission time Handle Problem Language Result Execution time Memory
688513 2023-01-27T15:51:33 Z nhphucqt ICC (CEOI16_icc) C++17
0 / 100
5 ms 468 KB
#include <bits/stdc++.h>
#include "icc.h"

using namespace std;

const int N = 107;
int fa[N];
int nTotal, nLef, nRig;
int total[N], lef[N], rig[N];

int root (int x) {
    return fa[x] < 0 ? x : fa[x] = root(fa[x]);
}

void unite(int u, int v) {
    if (fa[u] > fa[v]) {
        swap(u, v);
    }
    fa[u] += fa[v];
    fa[v] = u;
}

void copy(int sizA, int A[], int &sizB, int B[]) {
    for (int i = 0; i < sizA; ++i) {
        B[i] = A[i];
    }
    sizB = sizA;
}

void divide(int sizA, int A[], int &sizB, int B[], int &sizC, int C[]) {
    sizB = sizC = 0;
    for (int i = 0; i < sizA/2; ++i) {
        B[sizB++] = A[i];
    }
    for (int i = sizA/2; i < sizA; ++i) {
        C[sizC++] = A[i];
    }
}

void run(int numNode) {
    memset(fa, -1, (numNode+1) * sizeof(int));
    int numComp = numNode;
    while (numComp-- > 1) {
        nTotal = 0;
        for (int i = 1; i <= numNode; ++i) {
            if (i == root(i)) {
                total[nTotal++] = i;
            }
        }
        for (int j = 0; j < 8; ++j) {
            nLef = 0;
            nRig = 0;
            for (int i = 0; i < nTotal; ++i) {
                if ((i>>j) & 1) {
                    lef[nLef++] = total[i];
                } else {
                    rig[nRig++] = total[i];
                }
            }
            cerr << "lef: ";
            for (int i = 0; i < nLef; ++i) {
                cerr << lef[i] << ' ';
            }
            cerr << '\n';
            cerr << "rig: ";
            for (int i = 0; i < nRig; ++i) {
                cerr << rig[i] << ' ';
            }
            cerr << '\n';
            if (query(nLef, nRig, lef, rig) == 1) {
                break;
            }
            cerr << "---\n";
        }
        while (nLef > 1 || nRig > 1) {
            if (query((nLef+1)/2, (nRig+1)/2, lef, rig) == 1) {
                nLef = (nLef+1)/2;
                nRig = (nRig+1)/2;
            } else {
                int cLef = 0;
                for (int i = (nLef+1)/2; i < nLef; ++i) {
                    lef[cLef++] = lef[i];
                }
                int cRig = 0;
                for (int i = (nRig+1)/2; i < nRig; ++i) {
                    rig[cRig++] = rig[i];
                }
                nLef = cLef;
                nRig = cRig;
            }
        }
        cerr << "Set road: " << lef[0] << ' ' << rig[0] << '\n';
        setRoad(lef[0], rig[0]);
    }
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 468 KB Wrong road!
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 468 KB Wrong road!
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 468 KB Wrong road!
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 468 KB Wrong road!
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 468 KB Wrong road!
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 468 KB Wrong road!
2 Halted 0 ms 0 KB -