Submission #205212

#TimeUsernameProblemLanguageResultExecution timeMemory
205212egekabasMeetings (JOI19_meetings)C++14
29 / 100
2869 ms1272 KiB
#include <bits/stdc++.h>
#include "meetings.h"
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long   ll;
typedef unsigned long long   ull;
typedef long double ld;
typedef pair<ll, ll>    pll;
typedef pair<ull, ull>    pull;
typedef pair<int, int>  pii;
typedef pair<ld, ld>  pld;
int p[2009];
void calc(int root, vector<int> all){
    if(all.size() <= 1) return;
    vector<pair<vector<int>, int>> groups;
    for(auto u : all){
        if(u == root) continue;
        int put = 0;
        for(auto &v : groups){
            if(v.ss == u){
                put = 1;
                v.ff.pb(u);
                continue;
            }
            int tmp = Query(root, u, v.ss);
            if(tmp == root) continue;
            put = 1;
            v.ss = tmp;
            v.ff.pb(u);
        }
        if(put == 0){
            groups.pb({{u}, u});
        }
    }
    for(auto v : groups){
        p[v.ss] = root;
        calc(v.ss, v.ff);
    }
        
}

void Solve(int n){
    vector<int> all;
    for(int i = 0; i < n; ++i)
        all.pb(i);
    calc(0, all);
    for(int i = 1; i < n; ++i)
        Bridge(min(i, p[i]), max(i, p[i]));
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...