이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "meetings.h"
#include <bits/stdc++.h>
#define pii pair<int, int>
#define F first
#define S second
using namespace std;
mt19937 rd(chrono::steady_clock::now().time_since_epoch().count());
void bridge(int u, int v)
{
Bridge(min(u, v), max(u, v));
}
void solve(vector<int> v)
{
if (v.size() == 1)
return;
if (v.size() == 2)
{
bridge(v[0], v[1]);
return;
}
shuffle(v.begin(), v.end(), rd);
// cerr << "solve " << v[0] << ' ' << v[1] << '\n';
// for(auto i : v)
// cout << i << ' ';
// cout << '\n';
vector<pii> res = {pii(v[0], v[0]), pii(v[1], v[1])};
vector<int> line;
for (int i = 2; i < v.size(); i++)
{
res.emplace_back(pii(Query(v[0], v[1], v[i]), v[i]));
if (res.back().F == res.back().S)
line.emplace_back(v[i]);
}
sort(res.begin(), res.end());
int last = res.front().F;
vector<int> child;
for (auto [i, j] : res)
{
if (i != last)
{
solve(child);
child.clear();
last = i;
}
child.emplace_back(j);
}
solve(child);
sort(line.begin(), line.end(), [&](int i, int j)
{ if(i == j) return false;
return Query(v[0], i, j) == i; });
line.insert(line.begin(), v[0]);
line.emplace_back(v[1]);
for (int i = 1; i < line.size(); i++)
bridge(line[i], line[i - 1]);
}
void Solve(int N)
{
vector<int> node;
for (int i = 0; i < N; i++)
node.emplace_back(i);
solve(node);
}
컴파일 시 표준 에러 (stderr) 메시지
meetings.cpp: In function 'void solve(std::vector<int>)':
meetings.cpp:34:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
34 | for (int i = 2; i < v.size(); i++)
| ~~^~~~~~~~~~
meetings.cpp:43:13: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
43 | for (auto [i, j] : res)
| ^
meetings.cpp:60:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
60 | for (int i = 1; i < line.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... |