이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "meetings.h"
using namespace std;
using pii = pair<int, int>;
#define X first
#define Y second
static vector<pii> ans;
static vector<int> u[2005];
static int piv;
int ask(int x, int y, int z){
return Query(x - 1, y - 1, z - 1) + 1;
}
void f(vector<int> v){
if(v.size() <= 2){
if(v.size() == 2) ans.emplace_back(v[0], v[1]);
return;
}
for(int i : v){
u[i].clear();
}
random_shuffle(v.begin(), v.end());
u[v[0]].push_back(v[0]);
u[v[1]].push_back(v[1]);
for(int i = 2; i < v.size(); i++){
int t = ask(v[0], v[1], v[i]);
u[t].push_back(v[i]);
}
vector<int> w;
for(int i : v){
if(u[i].empty()) continue;
w.push_back(i);
}
for(int i = 0; i < w.size(); i++) if(w[i] == v[0]) swap(w[0], w[i]);
for(int i = 0; i < w.size(); i++) if(w[i] == v[1]) swap(w[w.size() - 1], w[i]);
piv = w[0];
if(w.size() >= 4) sort(w.begin() + 1, w.end() - 1, [](int x, int y){
return ask(piv, x, y) == x;
});
for(int i = 1; i < w.size(); i++) ans.emplace_back(w[i - 1], w[i]);
for(int i : w) f(u[i]);
}
void Solve(int n){
vector<int> v;
for(int i = 1; i <= n; i++) v.push_back(i);
f(v);
for(pii i : ans) Bridge(min(i.X, i.Y) - 1, max(i.X, i.Y) - 1);
}
컴파일 시 표준 에러 (stderr) 메시지
meetings.cpp: In function 'void f(std::vector<int>)':
meetings.cpp:28:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i = 2; i < v.size(); i++){
~~^~~~~~~~~~
meetings.cpp:37:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i = 0; i < w.size(); i++) if(w[i] == v[0]) swap(w[0], w[i]);
~~^~~~~~~~~~
meetings.cpp:38:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i = 0; i < w.size(); i++) if(w[i] == v[1]) swap(w[w.size() - 1], w[i]);
~~^~~~~~~~~~
meetings.cpp:43:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i = 1; i < w.size(); i++) ans.emplace_back(w[i - 1], w[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... |