#include "meetings.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int mp[2020][2020];
int query(int x, int y, int z){
if (x==1){
if (y > z) swap(y, z);
if (mp[y][z]) return mp[y][z];
return mp[y][z] = Query(x-1, y-1, z-1) + 1;
}
return Query(x-1, y-1, z-1) + 1;
}
void answer(int x, int y){
Bridge(x-1, y-1);
}
void dfs(int s, vector<int> a){
vector<vector<int>> subtree;
for (auto &x:a){
bool flag = 0;
for (auto &V:subtree){
if (query(1, x, V[0])!=s){
flag = 1;
V.push_back(x);
break;
}
}
if (flag) continue;
subtree.emplace_back();
subtree.back().push_back(x);
}
for (auto &V:subtree){
vector<int> C = V;
while(C.size() > 1){
int x = C.back(); C.pop_back();
int y = C.back(); C.pop_back();
int z = query(1, x, y);
if (x==z) C.push_back(x);
if (y==z) C.push_back(y);
}
answer(s, C[0]);
V.erase(find(V.begin(), V.end(), C[0]));
dfs(C[0], V);
}
}
void Solve(int N) {
vector<int> a;
for (int i=2;i<=N;i++) a.push_back(i);
dfs(1, a);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
336 KB |
Output is correct |
2 |
Incorrect |
0 ms |
336 KB |
Wrong Answer [3] |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
336 KB |
Output is correct |
2 |
Incorrect |
0 ms |
336 KB |
Wrong Answer [3] |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
336 KB |
Output is correct |
2 |
Incorrect |
0 ms |
336 KB |
Wrong Answer [3] |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
127 ms |
8644 KB |
Wrong Answer [3] |
2 |
Halted |
0 ms |
0 KB |
- |