이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <utility>
#include <algorithm>
#include <math.h>
#include <vector>
#include <set>
#include <iostream>
#include "highway.h"
//#include "doll.h"
#define fori(i,n) for(int i=0;i<n;i++)
#define forn(i,n) for(int i=1;i<n;i++)
#define fort(i,m,n) for(int i=m;i<n;i++)
#define forib(i,n) for(int i=n-1;i>=0;i--)
#define fornb(i,n) for(int i=n-1;i>0;i--)
#define maxl 10000000000
#define con continue;
typedef long long lol;
using namespace std;
typedef vector<int> veci;
typedef pair<lol,lol> point;
lol sum=0;
void find_pair(int n, std::vector<int> U, std::vector<int> V, int A, int B) {
int m = U.size();
veci w(m);
lol toll = ask(w);
vector<vector<point>> cons(n);
fori(i,m){
cons[U[i]].push_back({V[i],i});
cons[V[i]].push_back({U[i],i});
}
veci ord;
vector<point>x;
x.push_back({0,-1});
veci p(n);
while(!x.empty()){
int cur=x.back().first;
int pp=x.back().second;
x.pop_back();
p[cur]=pp;
ord.push_back(pp);
fori(i,cons[cur].size()){
if(cons[cur][i].second!=pp){
x.push_back(cons[cur][i]);
}
}
}
int l=1,h=m;
while(l<h){
int mid=(l+h+1)/2;
fori(i,m){
w[i]=0;
}
fort(i,mid,h+1){
w[ord[i]]=1;
}
lol tol = ask(w);
if(tol==toll){
h=mid-1;
}else{
l=mid;
}
}
l=ord[l];
int s=0;
fori(i,n){
if(p[i]==l){
s=i;
break;
}
}
ord.resize(0);
x.push_back({s,-1});
while(!x.empty()){
int cur=x.back().first;
int pp=x.back().second;
x.pop_back();
p[cur]=pp;
ord.push_back(pp);
fori(i,cons[cur].size()){
if(cons[cur][i].second!=pp){
x.push_back(cons[cur][i]);
}
}
}
l=1,h=m;
while(l<h){
int mid=(l+h+1)/2;
fori(i,m){
w[i]=0;
}
fort(i,mid,h+1){
w[ord[i]]=1;
}
lol tol = ask(w);
if(tol==toll){
h=mid-1;
}else{
l=mid;
}
}
l=ord[l];
int t=0;
fori(i,n){
if(p[i]==l){
t=i;
break;
}
}
answer(s, t);
}
컴파일 시 표준 에러 (stderr) 메시지
highway.cpp: In function 'void find_pair(int, std::vector<int>, std::vector<int>, int, int)':
highway.cpp:9:32: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
#define fori(i,n) for(int i=0;i<n;i++)
highway.cpp:41:8:
fori(i,cons[cur].size()){
~~~~~~~~~~~~~~~~~~
highway.cpp:41:3: note: in expansion of macro 'fori'
fori(i,cons[cur].size()){
^~~~
highway.cpp:9:32: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
#define fori(i,n) for(int i=0;i<n;i++)
highway.cpp:81:8:
fori(i,cons[cur].size()){
~~~~~~~~~~~~~~~~~~
highway.cpp:81:3: note: in expansion of macro 'fori'
fori(i,cons[cur].size()){
^~~~
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |