이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "meetings.h"
#include <bits/stdc++.h>
using namespace std;
void solve(vector<int> V) {
if (V.size() < 2) return;
int a = V[rand()%V.size()], b = V[rand()%V.size()];
while (b == a) {
b = V[rand()%V.size()];
}
map<int, vector<int>> subtrees;
vector<int> roots = {a};
map<int, bool> seen, pushed;
seen[a] = seen[b] = true;
for (int i : V) {
if (seen[i]) continue;
int c = Query(i, a, b);
if (c == i) {
roots.push_back(c);
pushed[c] = true;
}
seen[c] = true;
subtrees[c].push_back(i);
if (!seen[c]) {
roots.push_back(c);
seen[c] = true;
}
}
roots.push_back(b);
sort(roots.begin(), roots.end(), [&](const int &i, const int &j) {
return i == a || j == b ? true : i == b || j == a ? false : Query(a, i, j) == i;
});
for (int i = 0; i+1 < roots.size(); i++) {
Bridge(min(roots[i], roots[i+1]), max(roots[i], roots[i+1]));
}
//cerr << "Path: " << a << ", " << b << '\n';
for (int i : roots) {
if (!pushed[i]) {
subtrees[i].push_back(i);
}
//cerr << "Root: " << i << '\n';
solve(subtrees[i]);
}
}
void Solve(int N) {
srand(time(NULL));
vector<int> v(N);
iota(v.begin(), v.end(), 0);
solve(v);
}
컴파일 시 표준 에러 (stderr) 메시지
meetings.cpp: In function 'void solve(std::vector<int>)':
meetings.cpp:35:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
35 | for (int i = 0; i+1 < roots.size(); i++) {
| ~~~~^~~~~~~~~~~~~~
# | 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... |