| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 566626 | hoanghq2004 | 통행료 (IOI18_highway) | C++14 | 243 ms | 18688 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include "highway.h"
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
void find_pair(int n, vector<int> U, vector<int> V, int A, int B) {
vector <vector <pair <int, int>>> g(n), e(n);
vector <int> ord(n), id(n, -1);
int m = U.size();
for (int i = 0; i < m; ++i) {
g[U[i]].push_back({V[i], i});
g[V[i]].push_back({U[i], i});
}
int L = 0, R = m - 1;
vector <int> w(m, 0);
long long tot = ask(w);
while (L < R) {
int mid = L + R >> 1;
vector <int> w(m, 0);
for (int i = mid + 1; i < m; ++i) w[i] = 1;
if (ask(w) != tot) L = mid + 1;
else R = mid;
}
int x = L;
queue <int> q;
q.push(U[x]);
q.push(V[x]);
vector <int> type(n, -1);
type[U[x]] = 0;
type[V[x]] = 1;
while (q.size()) {
int u = q.front();
q.pop();
for (auto [v, i]: g[u]) {
if (type[v] != -1) continue;
type[v] = type[u];
id[v] = i;
e[u].push_back({v, i});
q.push(v);
}
}
int ti = 0;
function <void(int)> dfs = [&](int u) {
ord[ti++] = u;
for (auto [v, i]: e[u]) {
dfs(v);
}
};
dfs(U[x]);
w.assign(m, -1);
for (int i = 0; i < n; ++i) {
if (i == U[x] || i == V[x]) continue;
w[id[i]] = 0;
}
w[x] = 0;
for (int i = 0; i < m; ++i) if (w[i] == -1) w[i] = 1;
tot = ask(w);
L = 0, R = ti - 1;
while (L < R) {
int mid = L + R >> 1;
vector <int> w(m, -1);
for (int i = 0; i <= mid; ++i) {
if (ord[i] == U[x] || ord[i] == V[x]) continue;
if (type[ord[i]] == 0) w[id[ord[i]]] = 0;
}
for (int i = 0; i < n; ++i) {
if (i == U[x] || i == V[x]) continue;
if (type[i] == 1) w[id[i]] = 0;
}
w[x] = 0;
for (int i = 0; i < m; ++i) if (w[i] == -1) w[i] = 1;
if (ask(w) == tot) R = mid;
else L = mid + 1;
}
int S = ord[L];
ti = 0;
dfs(V[x]);
L = 0, R = ti - 1;
while (L < R) {
int mid = L + R >> 1;
vector <int> w(m, -1);
for (int i = 0; i <= mid; ++i) {
if (ord[i] == U[x] || ord[i] == V[x]) continue;
if (type[ord[i]] == 1) w[id[ord[i]]] = 0;
}
for (int i = 0; i < n; ++i) {
if (i == U[x] || i == V[x]) continue;
if (type[i] == 0) w[id[i]] = 0;
}
w[x] = 0;
for (int i = 0; i < m; ++i) if (w[i] == -1) w[i] = 1;
if (ask(w) == tot) R = mid;
else L = mid + 1;
}
int T = ord[L];
answer(S, T);
}
컴파일 시 표준 에러 (stderr) 메시지
| # | 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... | ||||
