이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "highway.h"
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pull;
typedef pair<ll, ll> pii;
typedef pair<ld, ld> pld;
vector<int> w;
vector<pii> g[100000];
int vis[100000];
vector<pii> vec[2];
ll begval;
int get(vector<pii> &vec){
int l = 0, r = vec.size()-1;
while(l < r){
int m = (l+r)/2;
for(int i = m+1; i <= r; ++i)
w[vec[i].ss] = 1;
if(ask(w) == begval)
r = m;
else
l = m+1;
for(int i = m+1; i <= r; ++i)
w[vec[i].ss] = 0;
}
return vec[l].ff;
}
void find_pair(int N, std::vector<int> U, std::vector<int> V, int A, int B) {
w.resize(U.size());
for(int i = 0; i < U.size(); ++i){
g[U[i]].pb({V[i], i});
g[V[i]].pb({U[i], i});
}
begval = ask(w);
int l = 0, r = U.size()-1;
while(l < r){
int m = (l+r)/2;
for(int i = l; i <= m; ++i)
w[i] = 1;
if(ask(w) != begval)
r = m;
else
l = m+1;
for(int i = l; i <= m; ++i)
w[i] = 0;
}
int e = l;
queue<pair<int, pii>> q;
q.push({0, {U[e], e}});
q.push({1, {V[e], e}});
vis[U[e]] = vis[V[e]] = 1;
while(q.size()){
int type = q.front().ff;
int v = q.front().ss.ff;
int come = q.front().ss.ss;
q.pop();
vec[type].pb({v, come});
for(auto u : g[v])
if(vis[u.ff] == 0){
vis[u.ff] = 1;
q.push({type, u});
}
}
answer(get(vec[0]), get(vec[1]));
}
컴파일 시 표준 에러 (stderr) 메시지
highway.cpp: In function 'void find_pair(int, std::vector<int>, std::vector<int>, int, int)':
highway.cpp:39:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
39 | for(int i = 0; i < U.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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |