Submission #1190808

#TimeUsernameProblemLanguageResultExecution timeMemory
1190808Ghulam_JunaidMeetings (JOI19_meetings)C++20
0 / 100
27 ms700 KiB
#include <bits/stdc++.h>
#include "meetings.h"
using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int MXN = 2005;
int n, root;
vector<int> subt[MXN];

bool cmp(int u, int v){
    return (Query(root, u, v) == u);
}

void get(int v){
    int u = subt[v][rng() % subt[v].size()];
    vector<int> path, cur_subt = subt[v];
    subt[v].clear();
    
    for (int x : cur_subt){
        if (x == u) continue;
        int cen = Query(u, x, v);

        if (cen == x)
            path.push_back(x);
        else
            subt[cen].push_back(x);
    }

    root = v;
    sort(path.begin(), path.end(), cmp);
    path.push_back(u);
    
    for (int i = 0; i < path.size(); i ++)
        Bridge(root, path[i]), root = path[i];
}

void Solve(int nn) {
    n = nn;
    for (int i = 1; i < n; i ++)
        subt[0].push_back(i);

    for (int v = 0; v < n; v ++){
        if (subt[v].empty()) continue;
        get(v);
        v--;
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...