# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1013809 |
2024-07-04T06:18:05 Z |
김은성(#10850) |
Highway Tolls (IOI18_highway) |
C++17 |
|
61 ms |
13544 KB |
//#define SUB
#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;
if(ch[u])
continue;
edge[u] = graph[v][i].first;
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;
#ifdef SUB
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].first] = 0;
ll ret2 = ask(toll);
if(ret != ret2)
hi = mid;
else
lo = mid+1;
}
answer(0, e[lo].second);
#endif // SUB
#ifndef SUB
int lo = 0, hi = N-1, mid;
while(lo < hi){
if(hi-lo == 1){
answer(lo, hi);
return;
}
mid = (lo+hi)/2;
for(i=0; i<=mid-1; i++)
toll[i] = 0;
for(i=mid; i<=N-2; i++)
toll[i] = 1;
ll ret2 = ask(toll);
int delta = (ret2 - ret) / (B-A);
if(delta == 0)
hi = mid;
else if(delta == d)
lo = mid;
else{
answer(mid-(d-delta), mid+delta);
return;
}
}
#endif // SUB
}
Compilation message
highway.cpp: In function 'void dfs(int)':
highway.cpp:13: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]
13 | 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 |
Correct |
6 ms |
4184 KB |
Output is correct |
2 |
Correct |
13 ms |
5464 KB |
Output is correct |
3 |
Correct |
20 ms |
6488 KB |
Output is correct |
4 |
Correct |
54 ms |
13332 KB |
Output is correct |
5 |
Correct |
61 ms |
13544 KB |
Output is correct |
6 |
Correct |
60 ms |
13340 KB |
Output is correct |
7 |
Correct |
55 ms |
13392 KB |
Output is correct |
8 |
Correct |
46 ms |
13340 KB |
Output is correct |
9 |
Correct |
54 ms |
13392 KB |
Output is correct |
# |
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 |
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 |
- |