# |
제출 시각 |
아이디 |
문제 |
언어 |
결과 |
실행 시간 |
메모리 |
120287 |
2019-06-24T06:42:18 Z |
이온조(#2949) |
통행료 (IOI18_highway) |
C++14 |
|
51 ms |
3372 KB |
#include "highway.h"
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;
int n, M;
long long ori;
vector<pii> adj[90009];
int D[90009];
int any(vector<int> S) {
int K = S.size();
int l = 0, r = K-1;
while(l <= r) {
if(l == r) return S[l];
int m = l+r >> 1;
vector<int> W(M, 0);
for(int i=0; i<=m; i++) for(auto& it: adj[S[i]]) W[it.second] = 1;
if(ask(W) != ori) r = m-1;
else l = m+1;
}
return S[r+1];
}
vector<int> f(int root) {
int c = 1;
for(int i=0; i<n; i++) D[i] = 0;
queue<int> que; que.push(root); D[root] = 1;
while(que.size()) {
int sz = que.size();
while(sz--) {
int now; now = que.front(); que.pop();
for(auto& it: adj[now]) {
if(!D[it.first]) {
D[it.first] = c+1;
que.push(it.first);
}
}
}
++c;
}
vector<int> S;
for(int i=0; i<n; i++) S.push_back(i);
sort(S.begin(), S.end(), [&](int P, int Q) {return D[P] > D[Q];});
return S;
}
void find_pair(int N, vector<int> U, vector<int> V, int A, int B) {
n = N; M = U.size();
for(int i=0; i<M; i++) {
adj[U[i]].push_back({V[i], i});
adj[V[i]].push_back({U[i], i});
}
vector<int> W(M, 0); ori = ask(W);
vector<int> S = f(0);
reverse(S.begin(), S.end());
int P = any(f(any(S)));
int Q = any(f(P));
answer(P, Q);
}
Compilation message
highway.cpp: In function 'int any(std::vector<int>)':
highway.cpp:16:18: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
int m = l+r >> 1;
~^~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
2424 KB |
Output is correct |
2 |
Correct |
4 ms |
2424 KB |
Output is correct |
3 |
Incorrect |
5 ms |
2424 KB |
Output is incorrect: {s, t} is wrong. |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
2564 KB |
Output is incorrect: {s, t} is wrong. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
20 ms |
3196 KB |
Output is incorrect: {s, t} is wrong. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
6 ms |
2472 KB |
Output is incorrect: {s, t} is wrong. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
25 ms |
3372 KB |
Output is incorrect: {s, t} is wrong. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
51 ms |
3296 KB |
Output is incorrect: {s, t} is wrong. |
2 |
Halted |
0 ms |
0 KB |
- |