Submission #249438

#TimeUsernameProblemLanguageResultExecution timeMemory
249438cheehengMeetings (JOI19_meetings)C++14
29 / 100
3066 ms9188 KiB
#include "meetings.h"
#include <bits/stdc++.h>
using namespace std;

int lca[2005][2005];

void dfs(int u, vector<int> possible){
    for(int v: possible){
        if(u == v){throw;}
        bool boleh = true;
        for(int x: possible){
            if(lca[v][x] == v || lca[v][x] == u){
            }else{
                boleh = false;
                break;
            }
        }
        if(boleh){
            vector<int> possible2;
            for(int x: possible){
                if(lca[v][x] == v && v != x){
                    possible2.push_back(x);
                }
            }
            Bridge(min(u, v), max(u, v));
            dfs(v, possible2);
        }
    }
}

void Solve(int N) {
    lca[0][0] = 0;
    for(int i = 1; i < N; i ++){
        lca[0][i] = 0;
        lca[i][0] = 0;
    }
    for(int i = 1; i < N; i ++){
        lca[i][i] = i;
        for(int j = i+1; j < N; j ++){
            lca[i][j] = Query(0, i, j);
            lca[j][i] = lca[i][j];
        }
    }

    vector<int> possible;
    for(int i = 1; i < N; i ++){
        possible.push_back(i);
    }

    dfs(0, possible);
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...