답안 #173753

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
173753 2020-01-05T10:02:44 Z Ruxandra985 CEOI16_icc (CEOI16_icc) C++14
7 / 100
475 ms 676 KB
#include <bits/stdc++.h>
#include "icc.h"
using namespace std;


int f[110] , w[110] , a[110] , b[110] , fq[110];
int idk[110];

void run (int n){
    int i , cc , st , dr , mid , aux , p , q , l , r , elem;
    for (i=1;i<=n;i++)
        f[i] = i;

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


        /// vreau sa ma duc in jos cat pot pana gasesc intervalul care contine capetele

        while (true){

            /// o sa fac solutia aia mai proasta cu generat random pt ca nuj cum altcumva

            memset (fq , 0 , sizeof(fq));

            for (i=1;i<=( n - mc + 1) / 2 ;i++){
                idk[i] = idk[i-1] + (rand() % (n - mc + 1 - ( ( n - mc + 1) / 2 ) + i - idk[i-1])) + 1;
                fq[idk[i]] = 1;
                //printf ("%d ",idk[i]);
            }
            //printf ("\n");
            /// idk ar trebui sa fie (n - mc + 1) / 2 numere in ordine crescatoare
            p = q = 0;
            for (i=1;i<=n;i++){
                if (fq[f[i]] == 1)
                    a[p++] = i;
            }
            for (i=1;i<=n;i++){
                if (fq[f[i]] == 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

                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;
        }


    }


}

Compilation message

icc.cpp: In function 'void run(int)':
icc.cpp:10:13: warning: unused variable 'cc' [-Wunused-variable]
     int i , cc , st , dr , mid , aux , p , q , l , r , elem;
             ^~
icc.cpp:10:18: warning: unused variable 'st' [-Wunused-variable]
     int i , cc , st , dr , mid , aux , p , q , l , r , elem;
                  ^~
icc.cpp:10:23: warning: unused variable 'dr' [-Wunused-variable]
     int i , cc , st , dr , mid , aux , p , q , l , r , elem;
                       ^~
icc.cpp:10:28: warning: unused variable 'mid' [-Wunused-variable]
     int i , cc , st , dr , mid , aux , p , q , l , r , elem;
                            ^~~
icc.cpp:10:34: warning: unused variable 'aux' [-Wunused-variable]
     int i , cc , st , dr , mid , aux , p , q , l , r , elem;
                                  ^~~
icc.cpp:10:48: warning: unused variable 'l' [-Wunused-variable]
     int i , cc , st , dr , mid , aux , p , q , l , r , elem;
                                                ^
icc.cpp:10:52: warning: unused variable 'r' [-Wunused-variable]
     int i , cc , st , dr , mid , aux , p , q , l , r , elem;
                                                    ^
icc.cpp:10:56: warning: unused variable 'elem' [-Wunused-variable]
     int i , cc , st , dr , mid , aux , p , q , l , r , elem;
                                                        ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 504 KB Ok! 97 queries used.
2 Correct 9 ms 504 KB Ok! 102 queries used.
# 결과 실행 시간 메모리 Grader output
1 Incorrect 368 ms 604 KB Number of queries more than 5000 out of 2500
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 475 ms 588 KB Number of queries more than 4500 out of 2250
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 421 ms 676 KB Number of queries more than 4000 out of 2000
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 436 ms 568 KB Number of queries more than 3550 out of 1775
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 336 ms 504 KB Number of queries more than 3250 out of 1625
2 Halted 0 ms 0 KB -