이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "highway.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN=9e4+5;
vector<int> g[MAXN], config;
vector<int> bons;
int aresta[MAXN*2][2];
int pid[MAXN], lvl[MAXN];
bool ruim[MAXN];
int n, m, x, y;
ll tam;
void pinta(int ini, int fim, int k) {
if(fim<ini||ini<0) return;
for(int i=ini; i<=fim; i++) config[pid[bons[i]]]=k;
}
void dfs(int cur, int pp, int d) {
pid[cur]=pp; lvl[cur]=d;
for(auto vid : g[cur]) {
if(vid==pp) continue;
int viz= aresta[vid][ aresta[vid][0]==cur ];
dfs(viz, vid, d+1);
}
}
// int divide(int cur) {
// return 1;
// for(auto vid : g[cur]) {
// }
// }
// int conquer(int cur) {
// }
void acaba() {
if(bons.size()==2) {
answer(bons[0], bons[1]);
return;
}
// for(auto cur : bons) printf("bb %d (%d)\n", cur, pid[cur]); cout << endl;
vector<int> aux;
int mid=bons.size()/2;
pinta(0, mid, 1);
int val=ask(config);
if(val==tam) {
for(int i=mid+1; i<bons.size(); i++) aux.push_back(bons[i]);
bons.clear();
for(auto cur : aux) bons.push_back(cur);
}
else if(val==tam+2*(y-x)) {
for(int i=0; i<=mid; i++) aux.push_back(bons[i]);
bons.clear();
for(auto cur : aux) bons.push_back(cur);
}
else {
random_shuffle(bons.begin(), bons.end());
}
pinta(0, mid, 0);
acaba();
}
void find_pair(int N, std::vector<int> U, std::vector<int> V, int A, int B) {
n=N; m=U.size(); x=A; y=B;
for(int i=0; i<m; i++) {
int a=U[i]; int b=V[i];
aresta[i][0]=a; aresta[i][1]=b;
g[a].push_back(i);
g[b].push_back(i);
config.push_back(0);
}
dfs(0, -1, 0);
tam=ask(config);
for(int i=1; i<n; i++) {
if(lvl[i]==tam) bons.push_back(i);
else ruim[i]=1;
}
for(int i=0; i<n; i++) {
if(ruim[i]) {
dfs(i, -1, 0);
break;
}
}
bons.push_back(0);
fill(config.begin(), config.end(), 0);
srand(time(0)+n+m); random_shuffle(bons.begin(), bons.end());
acaba();
}
컴파일 시 표준 에러 (stderr) 메시지
highway.cpp: In function 'void acaba()':
highway.cpp:53:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=mid+1; i<bons.size(); i++) aux.push_back(bons[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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |