이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "meetings.h"
#include <iostream>
#include <vector>
#include <algorithm>
#include <ctime>
#include <cstdlib>
using namespace std;
int A;
bool cmp(int x,int y)
{
return (Query(A,x,y)==x);
}
void solve(vector<int> v,int rad)
{
vector<int> path,aux;
vector< pair<int,int> > out;
if(v.empty()) return;
if(v.size()==1)
{
Bridge(rad,v[0]);
return;
}
int nod=v[rand()%v.size()],x;
for(int i=0;i<v.size();i++)
if(v[i]!=nod)
{
x=Query(rad,nod,v[i]);
if(x==v[i]) path.push_back(v[i]);
else out.push_back({x,v[i]});
}
A=rad;
if(path.size())
{
sort(path.begin(),path.end(),cmp);
Bridge(rad,path[0]);
Bridge(path.back(),nod);
for(int i=0;i+1<path.size();i++)
Bridge(path[i],path[i+1]);
}
else Bridge(rad,nod);
sort(out.begin(),out.end());
int j=0;
for(int i=0;i<out.size();i++)
{
aux.resize(0);
while(j<out.size()&&out[i].first==out[j].first)
{
aux.push_back(out[j].second);
j++;
}
solve(aux,out[i].first);
i=j-1;
}
}
void Solve(int N) {
srand(time(NULL));
vector<int> ini;
for(int i=1;i<N;i++)
ini.push_back(i);
solve(ini,0);
}
컴파일 시 표준 에러 (stderr) 메시지
meetings.cpp: In function 'void solve(std::vector<int>, int)':
meetings.cpp:24:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0;i<v.size();i++)
~^~~~~~~~~
meetings.cpp:37:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0;i+1<path.size();i++)
~~~^~~~~~~~~~~~
meetings.cpp:43:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0;i<out.size();i++)
~^~~~~~~~~~~
meetings.cpp:46:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
while(j<out.size()&&out[i].first==out[j].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... |