이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "meetings.h"
#include <bits/stdc++.h>
#define pii pair<int, int>
#define x first
#define y second
using namespace std;
const int N = 2e3+5;
void connect(int a, int b) {
if(a > b) swap(a, b);
Bridge(a, b);
}
void solve(vector<int> &vec) {
if(vec.size() <= 2) {
if(vec.size() == 2) connect(vec[0], vec[1]);
return;
}
int a = vec[0], b = vec[1];
map<int, vector<int> > mp;
for(int i = 2; i < vec.size(); i++) {
int now = Query(a, b, vec[i]);
mp[now].emplace_back(vec[i]);
}
vector<int> path;
for(auto p : mp) {
if(p.x == a) p.y.emplace_back(a);
else if(p.x == b) p.y.emplace_back(b);
else path.emplace_back(p.x);
solve(p.y);
}
sort(path.begin(), path.end(), [&](int x, int y) {
return Query(x, y, b) == y;
});
if(!path.empty()) {
connect(a, path[0]), connect(path.back(), b);
for(int i = 0; i < path.size() - 1; i++) connect(path[i], path[i + 1]);
} else connect(a, b);
}
void Solve(int n) {
vector<int> vec;
for(int i = 0; i < n; i++) vec.emplace_back(i);
solve(vec);
}
컴파일 시 표준 에러 (stderr) 메시지
meetings.cpp: In function 'void solve(std::vector<int>&)':
meetings.cpp:24:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i = 2; i < vec.size(); i++) {
~~^~~~~~~~~~~~
meetings.cpp:40:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i = 0; i < path.size() - 1; i++) connect(path[i], path[i + 1]);
~~^~~~~~~~~~~~~~~~~
# | 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... |