# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1038149 |
2024-07-29T13:32:12 Z |
elotelo966 |
Race (IOI11_race) |
C++17 |
|
143 ms |
23888 KB |
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx,avx2,fma")
#include <race.h>
#include <bits/stdc++.h>
using namespace std;
//#define int long long
#define OYY LLONG_MAX
#define mod 998244353
#define faster ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define FOR for(int i=1;i<=n;i++)
#define mid (start+end)/2
#define lim 100005
#define fi first
#define se second
typedef long long lo;
map<int,int> mp;
vector<pair<int,int>> noww;
vector<pair<int,int>> v[lim];
int x[lim],y[lim],l[lim];
int removed[lim],sub_tree[lim];
lo cev=LLONG_MAX,k;
inline int find_size(int node,int ata){
sub_tree[node]=1;
for(auto go:v[node]){
if(go.fi==ata || removed[go.fi])continue;
find_size(go.fi,node);
sub_tree[node]+=sub_tree[go.fi];
}
return sub_tree[node];
}
inline int find_centroid(int node,int ata,int cur_size){
for(auto go:v[node]){
if(go.fi==ata || removed[go.fi])continue;
if(sub_tree[go.fi]*2>cur_size)return find_centroid(go.fi,node,cur_size);
}
return node;
}
inline void dfs(int node,int ata,int cur,int sayac){
if(cur>k)return ;
noww.push_back({cur,sayac});
for(auto go:v[node]){
if(go.fi==ata || removed[go.fi])continue;
dfs(go.fi,node,cur+go.se,sayac+1);
}
}
inline void solve(int node){
mp.clear();
mp[0]=0;
for(auto go:v[node]){
if(removed[go.fi])continue;
noww.clear();
dfs(go.fi,node,go.se,1);
for(auto x:noww){
if(mp.find(k-x.fi)==mp.end()){
continue;
}
cev=min(cev,(lo)mp[k-x.fi]+x.se);
}
for(auto x:noww){
if(mp.find(x.fi)==mp.end())mp[x.fi]=x.se;
else mp[x.fi]=min(mp[x.fi],x.se);
}
}
}
inline void build(int node){
int cur_size=find_size(node,-1);
int cur_centroid=find_centroid(node,-1,cur_size);
removed[cur_centroid]=1;
solve(cur_centroid);
for(auto go:v[cur_centroid]){
if(removed[go.fi])continue;
build(go.fi);
}
}
int best_path(int N, int K, int H[][2], int L[])
{
int n=N;
k=K;
FOR{
if(i==1)continue;
x[i]=H[i-2][0];
y[i]=H[i-2][1];
l[i]=L[i-2];
v[x[i]].push_back({y[i],l[i]});
v[y[i]].push_back({x[i],l[i]});
}
build(0);
if(cev==LLONG_MAX)return -1;
else return cev;
}
/*
int32_t main(){
faster
int n;cin>>n>>k;
FOR{
if(i==1)continue;
cin>>x[i]>>y[i];
}
FOR{
if(i==1)continue;
cin>>l[i];
v[x[i]].push_back({y[i],l[i]});
v[y[i]].push_back({x[i],l[i]});
}
build(1);
if(cev==LLONG_MAX)cout<<-1<<'\n';
else cout<<cev<<'\n';
return 0;
}*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
8540 KB |
Output is correct |
2 |
Correct |
3 ms |
8284 KB |
Output is correct |
3 |
Correct |
2 ms |
8284 KB |
Output is correct |
4 |
Correct |
2 ms |
8348 KB |
Output is correct |
5 |
Correct |
2 ms |
8284 KB |
Output is correct |
6 |
Correct |
2 ms |
8284 KB |
Output is correct |
7 |
Correct |
2 ms |
8284 KB |
Output is correct |
8 |
Correct |
2 ms |
8284 KB |
Output is correct |
9 |
Correct |
2 ms |
8284 KB |
Output is correct |
10 |
Correct |
3 ms |
8284 KB |
Output is correct |
11 |
Correct |
2 ms |
8284 KB |
Output is correct |
12 |
Correct |
2 ms |
8284 KB |
Output is correct |
13 |
Correct |
2 ms |
8284 KB |
Output is correct |
14 |
Correct |
2 ms |
8284 KB |
Output is correct |
15 |
Correct |
2 ms |
8284 KB |
Output is correct |
16 |
Correct |
2 ms |
8284 KB |
Output is correct |
17 |
Correct |
2 ms |
8280 KB |
Output is correct |
18 |
Correct |
2 ms |
8424 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
8540 KB |
Output is correct |
2 |
Correct |
3 ms |
8284 KB |
Output is correct |
3 |
Correct |
2 ms |
8284 KB |
Output is correct |
4 |
Correct |
2 ms |
8348 KB |
Output is correct |
5 |
Correct |
2 ms |
8284 KB |
Output is correct |
6 |
Correct |
2 ms |
8284 KB |
Output is correct |
7 |
Correct |
2 ms |
8284 KB |
Output is correct |
8 |
Correct |
2 ms |
8284 KB |
Output is correct |
9 |
Correct |
2 ms |
8284 KB |
Output is correct |
10 |
Correct |
3 ms |
8284 KB |
Output is correct |
11 |
Correct |
2 ms |
8284 KB |
Output is correct |
12 |
Correct |
2 ms |
8284 KB |
Output is correct |
13 |
Correct |
2 ms |
8284 KB |
Output is correct |
14 |
Correct |
2 ms |
8284 KB |
Output is correct |
15 |
Correct |
2 ms |
8284 KB |
Output is correct |
16 |
Correct |
2 ms |
8284 KB |
Output is correct |
17 |
Correct |
2 ms |
8280 KB |
Output is correct |
18 |
Correct |
2 ms |
8424 KB |
Output is correct |
19 |
Correct |
2 ms |
8284 KB |
Output is correct |
20 |
Correct |
2 ms |
8284 KB |
Output is correct |
21 |
Correct |
4 ms |
8424 KB |
Output is correct |
22 |
Correct |
3 ms |
8284 KB |
Output is correct |
23 |
Correct |
3 ms |
8284 KB |
Output is correct |
24 |
Correct |
3 ms |
8284 KB |
Output is correct |
25 |
Correct |
3 ms |
8284 KB |
Output is correct |
26 |
Correct |
2 ms |
8284 KB |
Output is correct |
27 |
Correct |
2 ms |
8284 KB |
Output is correct |
28 |
Correct |
3 ms |
8284 KB |
Output is correct |
29 |
Correct |
3 ms |
8280 KB |
Output is correct |
30 |
Correct |
3 ms |
8284 KB |
Output is correct |
31 |
Correct |
3 ms |
8284 KB |
Output is correct |
32 |
Correct |
3 ms |
8284 KB |
Output is correct |
33 |
Correct |
4 ms |
8540 KB |
Output is correct |
34 |
Correct |
3 ms |
8284 KB |
Output is correct |
35 |
Correct |
2 ms |
8284 KB |
Output is correct |
36 |
Correct |
2 ms |
8284 KB |
Output is correct |
37 |
Correct |
3 ms |
8284 KB |
Output is correct |
38 |
Correct |
3 ms |
8284 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
8540 KB |
Output is correct |
2 |
Correct |
3 ms |
8284 KB |
Output is correct |
3 |
Correct |
2 ms |
8284 KB |
Output is correct |
4 |
Correct |
2 ms |
8348 KB |
Output is correct |
5 |
Correct |
2 ms |
8284 KB |
Output is correct |
6 |
Correct |
2 ms |
8284 KB |
Output is correct |
7 |
Correct |
2 ms |
8284 KB |
Output is correct |
8 |
Correct |
2 ms |
8284 KB |
Output is correct |
9 |
Correct |
2 ms |
8284 KB |
Output is correct |
10 |
Correct |
3 ms |
8284 KB |
Output is correct |
11 |
Correct |
2 ms |
8284 KB |
Output is correct |
12 |
Correct |
2 ms |
8284 KB |
Output is correct |
13 |
Correct |
2 ms |
8284 KB |
Output is correct |
14 |
Correct |
2 ms |
8284 KB |
Output is correct |
15 |
Correct |
2 ms |
8284 KB |
Output is correct |
16 |
Correct |
2 ms |
8284 KB |
Output is correct |
17 |
Correct |
2 ms |
8280 KB |
Output is correct |
18 |
Correct |
2 ms |
8424 KB |
Output is correct |
19 |
Correct |
128 ms |
15192 KB |
Output is correct |
20 |
Correct |
143 ms |
15244 KB |
Output is correct |
21 |
Correct |
137 ms |
15576 KB |
Output is correct |
22 |
Correct |
114 ms |
15712 KB |
Output is correct |
23 |
Correct |
50 ms |
15444 KB |
Output is correct |
24 |
Correct |
57 ms |
15336 KB |
Output is correct |
25 |
Correct |
93 ms |
16504 KB |
Output is correct |
26 |
Correct |
66 ms |
18900 KB |
Output is correct |
27 |
Runtime error |
40 ms |
23888 KB |
Execution killed with signal 11 |
28 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
8540 KB |
Output is correct |
2 |
Correct |
3 ms |
8284 KB |
Output is correct |
3 |
Correct |
2 ms |
8284 KB |
Output is correct |
4 |
Correct |
2 ms |
8348 KB |
Output is correct |
5 |
Correct |
2 ms |
8284 KB |
Output is correct |
6 |
Correct |
2 ms |
8284 KB |
Output is correct |
7 |
Correct |
2 ms |
8284 KB |
Output is correct |
8 |
Correct |
2 ms |
8284 KB |
Output is correct |
9 |
Correct |
2 ms |
8284 KB |
Output is correct |
10 |
Correct |
3 ms |
8284 KB |
Output is correct |
11 |
Correct |
2 ms |
8284 KB |
Output is correct |
12 |
Correct |
2 ms |
8284 KB |
Output is correct |
13 |
Correct |
2 ms |
8284 KB |
Output is correct |
14 |
Correct |
2 ms |
8284 KB |
Output is correct |
15 |
Correct |
2 ms |
8284 KB |
Output is correct |
16 |
Correct |
2 ms |
8284 KB |
Output is correct |
17 |
Correct |
2 ms |
8280 KB |
Output is correct |
18 |
Correct |
2 ms |
8424 KB |
Output is correct |
19 |
Correct |
2 ms |
8284 KB |
Output is correct |
20 |
Correct |
2 ms |
8284 KB |
Output is correct |
21 |
Correct |
4 ms |
8424 KB |
Output is correct |
22 |
Correct |
3 ms |
8284 KB |
Output is correct |
23 |
Correct |
3 ms |
8284 KB |
Output is correct |
24 |
Correct |
3 ms |
8284 KB |
Output is correct |
25 |
Correct |
3 ms |
8284 KB |
Output is correct |
26 |
Correct |
2 ms |
8284 KB |
Output is correct |
27 |
Correct |
2 ms |
8284 KB |
Output is correct |
28 |
Correct |
3 ms |
8284 KB |
Output is correct |
29 |
Correct |
3 ms |
8280 KB |
Output is correct |
30 |
Correct |
3 ms |
8284 KB |
Output is correct |
31 |
Correct |
3 ms |
8284 KB |
Output is correct |
32 |
Correct |
3 ms |
8284 KB |
Output is correct |
33 |
Correct |
4 ms |
8540 KB |
Output is correct |
34 |
Correct |
3 ms |
8284 KB |
Output is correct |
35 |
Correct |
2 ms |
8284 KB |
Output is correct |
36 |
Correct |
2 ms |
8284 KB |
Output is correct |
37 |
Correct |
3 ms |
8284 KB |
Output is correct |
38 |
Correct |
3 ms |
8284 KB |
Output is correct |
39 |
Correct |
128 ms |
15192 KB |
Output is correct |
40 |
Correct |
143 ms |
15244 KB |
Output is correct |
41 |
Correct |
137 ms |
15576 KB |
Output is correct |
42 |
Correct |
114 ms |
15712 KB |
Output is correct |
43 |
Correct |
50 ms |
15444 KB |
Output is correct |
44 |
Correct |
57 ms |
15336 KB |
Output is correct |
45 |
Correct |
93 ms |
16504 KB |
Output is correct |
46 |
Correct |
66 ms |
18900 KB |
Output is correct |
47 |
Runtime error |
40 ms |
23888 KB |
Execution killed with signal 11 |
48 |
Halted |
0 ms |
0 KB |
- |