답안 #173750

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


int f[110] , w[110] , a[110] , b[110];
pair <int,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
            idk[1] = make_pair(0 , 1);
            for (i=2;i<=n - mc + 1;i++){
                idk[i] = make_pair(rand() , i);
            }

            sort (idk + 2 , idk + n - mc + 1 + 1);
            p = q = 0;
            for (cc = 1 ; cc <= (n - mc + 1) / 2 ; cc++){
                for (i=1;i<=n;i++){
                    if (f[i] == idk[cc].second)
                        a[p++] = i;
                }
            }
            for (cc = (n - mc + 1) / 2 + 1 ; cc <= n - mc + 1 ; cc++){
                for (i=1;i<=n;i++){
                    if (f[i] == idk[cc].second)
                        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: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 Incorrect 183 ms 504 KB Number of queries more than 3000 out of 1500
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 40 ms 504 KB Ok! 546 queries used.
2 Incorrect 364 ms 588 KB Number of queries more than 5000 out of 2500
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 151 ms 504 KB Ok! 1550 queries used.
2 Incorrect 458 ms 568 KB Number of queries more than 4500 out of 2250
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 361 ms 632 KB Number of queries more than 4000 out of 2000
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 190 ms 560 KB Too many queries! 1900 out of 1775
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 192 ms 560 KB Too many queries! 1919 out of 1625
2 Halted 0 ms 0 KB -