# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1013802 |
2024-07-04T06:07:53 Z |
김은성(#10850) |
Highway Tolls (IOI18_highway) |
C++17 |
|
8 ms |
4184 KB |
#include "highway.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<pair<int, int> > graph[90009];
int edge[90009];
int depth[90009];
bool ch[90009];
void dfs(int v){
ch[v] = 1;
int i;
for(i=0; i<graph[v].size(); i++){
int u = graph[v][i].second;
edge[u] = graph[v][i].first;
if(ch[u])
continue;
depth[u] = depth[v] + 1;
dfs(u);
}
}
void find_pair(int N, std::vector<int> U, std::vector<int> V, int A, int B) {
int M = U.size(), i;
vector<int> toll(M);
for(i=0; i<M; i++){
graph[U[i]].push_back(make_pair(i, V[i]));
graph[V[i]].push_back(make_pair(i, U[i]));
}
dfs(0);
ll ret = ask(toll);
int d = (ll)ret / A;
vector<pair<int, int> > e;
for(i=0; i<N; i++){
if(depth[i] == d){
e.push_back(make_pair(edge[i], i));
}
}
int lo = 0, hi = (int)e.size() - 1, mid;
while(lo < hi){
mid = (lo+hi)/2;
for(i=0; i<=mid; i++)
toll[e[i].first] = 1;
for(i=mid+1; i<=hi; i++)
toll[e[i].second] = 0;
ll ret2 = ask(toll);
if(ret != ret2)
hi = mid;
else
lo = mid+1;
}
answer(0, e[lo].second);
}
Compilation message
highway.cpp: In function 'void dfs(int)':
highway.cpp:12:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
12 | for(i=0; i<graph[v].size(); i++){
| ~^~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
3160 KB |
Output is incorrect: {s, t} is wrong. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
3160 KB |
Output is incorrect: {s, t} is wrong. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
7 ms |
4184 KB |
Output is incorrect: {s, t} is wrong. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
3160 KB |
Output is incorrect: {s, t} is wrong. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
8 ms |
3928 KB |
Output is incorrect: {s, t} is wrong. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
7 ms |
3928 KB |
Output is incorrect: {s, t} is wrong. |
2 |
Halted |
0 ms |
0 KB |
- |