Submission #688509

# Submission time Handle Problem Language Result Execution time Memory
688509 2023-01-27T15:25:15 Z nhphucqt ICC (CEOI16_icc) C++17
0 / 100
1 ms 340 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) {
        int cnt = 0;
        nTotal = 0;
        for (int i = 1; i <= numNode; ++i) {
            if (i == root(i)) {
                total[nTotal++] = i;
            }
        }
        for (int j = 0; j < 8; ++j) {
            for (int i = 0; i < nTotal; ++i) {
                if ((j>>i) & 1) {
                    lef[nLef++] = total[i];
                } else {
                    rig[nRig++] = total[i];
                }
            }
            if (query(nLef, nRig, lef, rig) == 1) {
                break;
            }
        }
        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;
            }
        }
        setRoad(lef[0], rig[0]);
    }
}

Compilation message

icc.cpp: In function 'void run(int)':
icc.cpp:44:13: warning: unused variable 'cnt' [-Wunused-variable]
   44 |         int cnt = 0;
      |             ^~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB The query sets must be disjoint
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 308 KB The query sets must be disjoint
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB The query sets must be disjoint
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB The query sets must be disjoint
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 340 KB The query sets must be disjoint
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 308 KB The query sets must be disjoint
2 Halted 0 ms 0 KB -