제출 #263227

#제출 시각아이디문제언어결과실행 시간메모리
263227UserIsUndefinedHighway Tolls (IOI18_highway)C++14
0 / 100
24 ms3740 KiB
#include "highway.h"
#include <bits/stdc++.h>

using namespace std;

int depth ;

vector<pair<int,int>> adj[90005];
vector<int> can;

void dfs(int v , int dep, int p, int idx){
    if (dep == depth){
        can.push_back(idx);
        return;
    }


    for (pair<int,int> e : adj[v]){
        if (e.first != p){
            dfs(e.first, dep + 1 , v, e.second);
        }
    }

}


void find_pair(int N, std::vector<int> U, std::vector<int> V, int A, int B) {
    int m = V.size();

    vector<int> ans;

    vector<int> test(m , 0);



    long long li = ask(test);

    depth = li/A;




    for (int i = 0 ; i < m ; i++){
        adj[U[i]].push_back({V[i], i});
        adj[V[i]].push_back({U[i], i});
    }



    dfs(0, 0 , -1, -1);



//    for (int cand : can){
//        cout << "This is cand" << cand << endl;
//    }


    int low = 0;
    int high = can.size() - 1;

    while(low <= high){
        int mid = (low + high)/2;

        vector<int> call(m);

        for (int i = low ; i <= mid ; i++){
            call[can[i]] = 1;
        }

        long long an = ask(call);

        if (an - B + A == li){
            high = mid;
        }
        else {
            low = mid + 1;
        }




    }





    answer(0 , low - 1);


}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...