이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <vector>
#include <map>
#include <algorithm>
#include <cstdlib>
#include "meetings.h"
using namespace std;
struct cmp{
int a;
cmp(int b){
a=b;
}
bool operator()(int x, int y){
if(x==a) return y!=a;
if(y==a) return false;
return Query(a, x, y)==x;
}
};
void SolveSubTree(vector<int> nodes){
if(nodes.size()<=1) return;
int a=rand()%nodes.size(), b=rand()%nodes.size();
while(a==b){
b=rand()%nodes.size();
}
a=nodes[a];b=nodes[b];
map<int, vector<int>> sts;
sts[a].push_back(a);
sts[b].push_back(b);
for(int j=0;j<nodes.size();++j){
if(nodes[j]!=a && nodes[j]!=b){
int x = Query(a, b, nodes[j]);
sts[x].push_back(nodes[j]);
}
}
vector<int> path;
for(auto i:sts){
path.push_back(i.first);
}
sort(path.begin(), path.end(), cmp(a));
for(int i=1;i<path.size();++i){
int x=min(path[i-1], path[i]);
int y=max(path[i-1], path[i]);
Bridge(x, y);
}
for(auto i:sts){
SolveSubTree(i.second);
}
}
void Solve(int N) {
vector<int> s;
for(int i=0;i<N;++i) s.push_back(i);
SolveSubTree(s);
}
컴파일 시 표준 에러 (stderr) 메시지
meetings.cpp: In function 'void SolveSubTree(std::vector<int>)':
meetings.cpp:33:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int j=0;j<nodes.size();++j){
~^~~~~~~~~~~~~
meetings.cpp:46:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=1;i<path.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... |