#include "highway.h"
#include<bits/stdc++.h>
using namespace std;
vector<pair<int, int>> adj[100100];
int dep[100100], par[100100];
void dfs(int n, int p = -1, int d = 0) {
dep[n] = d;
for(auto i: adj[n])
if(i.first!=p)
dfs(i.first, n, d+1), par[i.first] = i.second;
}
void find_pair(int N, std::vector<int> U, std::vector<int> V, int A, int B) {
for(int i = 0; i < N-1; i++)
adj[U[i]].push_back({V[i], i}), adj[V[i]].push_back({U[i], i});
dfs(0);
int M = U.size();
std::vector<int> w(M, 0);
long long toll = ask(w);
int dis = toll/A;
vector<int> x;
for(int i = 0; i < N; i++)
if(dep[i]==dis)
x.push_back(i);
while(x.size() > 1) {
vector<int> a,b,c(N-1,0);
for(int i = 0; i < x.size()/2; i++) {
a.push_back(x[i]);
c[par[x[i]]] = 1;
}
for(int i = x.size()/2; i < x.size(); i++) {
b.push_back(x[i]);
}
if(ask(c)>toll)
x = a;
else
x = b;
}
answer(0, x[0]);
}
Compilation message
highway.cpp: In function 'void find_pair(int, std::vector<int>, std::vector<int>, int, int)':
highway.cpp:26:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
26 | for(int i = 0; i < x.size()/2; i++) {
| ~~^~~~~~~~~~~~
highway.cpp:30:35: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
30 | for(int i = x.size()/2; i < x.size(); i++) {
| ~~^~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
2640 KB |
Output is correct |
2 |
Correct |
1 ms |
2640 KB |
Output is correct |
3 |
Correct |
1 ms |
2664 KB |
Output is correct |
4 |
Correct |
1 ms |
2640 KB |
Output is correct |
5 |
Correct |
2 ms |
2640 KB |
Output is correct |
6 |
Correct |
1 ms |
2640 KB |
Output is correct |
7 |
Correct |
2 ms |
2640 KB |
Output is correct |
8 |
Correct |
2 ms |
2664 KB |
Output is correct |
9 |
Correct |
1 ms |
2640 KB |
Output is correct |
10 |
Correct |
1 ms |
2640 KB |
Output is correct |
11 |
Correct |
2 ms |
2640 KB |
Output is correct |
12 |
Correct |
1 ms |
2640 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
2640 KB |
Output is correct |
2 |
Correct |
12 ms |
3236 KB |
Output is correct |
3 |
Correct |
61 ms |
8952 KB |
Output is correct |
4 |
Correct |
53 ms |
8988 KB |
Output is correct |
5 |
Correct |
94 ms |
8872 KB |
Output is correct |
6 |
Correct |
101 ms |
8812 KB |
Output is correct |
7 |
Correct |
83 ms |
8900 KB |
Output is correct |
8 |
Correct |
65 ms |
8984 KB |
Output is correct |
9 |
Correct |
106 ms |
8852 KB |
Output is correct |
10 |
Correct |
98 ms |
8992 KB |
Output is correct |
11 |
Correct |
75 ms |
9064 KB |
Output is correct |
12 |
Correct |
66 ms |
9448 KB |
Output is correct |
13 |
Correct |
77 ms |
9200 KB |
Output is correct |
14 |
Correct |
73 ms |
8852 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
9 ms |
3536 KB |
Output is incorrect: {s, t} is wrong. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
2640 KB |
Output is incorrect: {s, t} is wrong. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
229 ms |
262144 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
229 ms |
262144 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |