Submission #173854

# Submission time Handle Problem Language Result Execution time Memory
173854 2020-01-05T14:29:36 Z Ruxandra985 ICC (CEOI16_icc) C++14
7 / 100
181 ms 632 KB
#include <bits/stdc++.h>
#include "icc.h"
using namespace std;


int f[110] , w[110] , a[110] , b[110] , aib[110];
int query (int p){
    int sol = 0;
    for (int i = p ; i ; i = i - (i & (-i)))
        sol+= aib[i];
    return sol;
}
void update (int p){

    for (int i = p ; i <= 100 ; i = i + (i & (-i)))
        aib[i]++;

}
void run (int n){
    int i , p , q , bit;
    for (i=1;i<=n;i++)
        f[i] = i;

    for (int mc = 1 ; mc < n ; mc++){

        memset ( aib , 0 , sizeof (aib));
        /// vreau sa ma duc in jos cat pot pana gasesc intervalul care contine capetele
        bit = 0;
        while (true){

            /// o sa fac solutia aia mai proasta cu generat random pt ca nuj cum altcumva
            bit = rand() % 7;
            bit += query(bit + 1);
            update(bit + 1);
            p = q = 0;
            for (i=1;i<=n;i++){
                if (f[i] & (1 << bit))
                    a[p++] = i;
            }

            for (i=1;i<=n;i++){
                if ((f[i] & (1 << bit)) == 0)
                    b[q++] = i;
            }


            if (query( p , q , a , b ) == 1){
                /// un capat de muchie e intr o jumatate , celalalt capat in cealalta
                break;
            }
            else {
                /// ambele capete sunt in aceeasi jum
                bit++;
                continue;

            }

        }

        /// ai vectorii a si b
        /// a are p elem si b are q
        /// a si b sunt indexate de la 0

        /// pt a

        while (p > 1){

            if (query (p / 2 , q , a , b) == 1)
                p/=2;
            else {
                for (i = p/2 ; i < p ; i++)
                    a[i - p/2] = a[i];
                p = p - p / 2;
            }

        }

        /// pt b

        while (q > 1){

            if (query (p , q / 2 , a , b) == 1)
                q/=2;
            else {
                for (i = q/2 ; i < q ; i++)
                    b[i - q/2] = b[i];
                q = q - q / 2;
            }

        }

        setRoad(a[0] , b[0]);

        /// acum trebuie sa modificam f ul
        int u1 = min( f[a[0]] , f[b[0]] );
        int u2 = max( f[a[0]] , f[b[0]] );

        for (i=1;i<=n;i++){
            if (f[i] == u2)
                f[i] = u1;
            else if (f[i] == n - mc + 1 && u2 != n - mc + 1)
                f[i] = u2;
        }


    }


}
# Verdict Execution time Memory Grader output
1 Correct 10 ms 504 KB Ok! 274 queries used.
2 Correct 10 ms 504 KB Ok! 161 queries used.
# Verdict Execution time Memory Grader output
1 Correct 47 ms 504 KB Ok! 857 queries used.
2 Incorrect 119 ms 632 KB Too many queries! 4192 out of 2500
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 164 ms 504 KB Too many queries! 2431 out of 2250
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 181 ms 504 KB Number of queries more than 4000 out of 2000
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 158 ms 584 KB Number of queries more than 3550 out of 1775
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 144 ms 564 KB Number of queries more than 3250 out of 1625
2 Halted 0 ms 0 KB -