이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "meetings.h"
using namespace std;
mt19937 rng(10072002);
void addEdge(int u, int v) {
if (u > v) swap(u, v);
Bridge(u, v);
}
void go(int from, vector<int> comp) {
int id = rng() % (comp.size());
int to = comp[id];
swap(comp[id], comp.back());
comp.pop_back();
vector<int> path;
vector<pair<int, int>> vals;
for (int v : comp) {
int u = Query(from, to, v);
if (u == v) {
path.push_back(v);
} else {
vals.emplace_back(u, v);
}
}
if (path.empty()) {
addEdge(from, to);
} else {
sort(path.begin(), path.end(), [&](int x, int y) {
return Query(from, x, y) == x;
});
addEdge(from, path[0]);
for (int i = 0; i + 1 < path.size(); ++i) {
addEdge(path[i], path[i + 1]);
}
addEdge(path.back(), to);
}
sort(vals.begin(), vals.end());
int l = 0;
while (l < vals.size()) {
vector<int> ncomp;
int r = l;
while (r < vals.size() && vals[l].first == vals[r].first) {
ncomp.push_back(vals[r++].second);
}
go(vals[l].first, ncomp);
l = r;
}
}
void Solve(int n) {
vector<int> all(n - 1);
iota(all.begin(), all.end(), 1);
go(0, all);
cout << "Test\n";
}
컴파일 시 표준 에러 (stderr) 메시지
meetings.cpp: In function 'void go(int, std::vector<int>)':
meetings.cpp:34:29: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 0; i + 1 < path.size(); ++i) {
~~~~~~^~~~~~~~~~~~~
meetings.cpp:41:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
while (l < vals.size()) {
~~^~~~~~~~~~~~~
meetings.cpp:44:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
while (r < vals.size() && vals[l].first == vals[r].first) {
~~^~~~~~~~~~~~~
# | 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... |