This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "meetings.h"
#include <bits/stdc++.h>
#define eb emplace_back
#define iter(a) a.begin(), a.end()
#define printv(a, b) { \
for(auto pv : a) b << pv << " "; \
b << "\n"; \
}
using namespace std;
typedef long long ll;
vector<vector<int>> anc;
bool comp(int a, int b){
return anc[a].size() < anc[b].size();
}
void ans(int u, int v){
if(u > v) swap(u, v);
//cerr << u << " " << v << "\n";
Bridge(u, v);
}
void Solve(int n){
vector<int> dpt(n);
anc.resize(n, vector<int>(1));
anc[0].clear();
for(int i = 1; i < n; i++){
for(int j = i + 1; j < n; j++){
int r = Query(0, i, j);
if(r != i) anc[i].eb(r);
if(r != j) anc[j].eb(r);
}
}
vector<int> tmp(n);
for(int i = 0; i < n; i++){
tmp[i] = i;
sort(iter(anc[i]));
anc[i].resize(unique(iter(anc[i])) - anc[i].begin());
dpt[i] = anc[i].size();
//cerr << i << " ";
//printv(anc[i], cerr);
}
sort(iter(tmp), comp);
for(int i : tmp){
if(i == 0) continue;
int mn = 0;
for(int j : anc[i]){
if(dpt[j] > dpt[mn]) mn = j;
}
ans(i, mn);
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |