# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
935724 |
2024-02-29T12:30:40 Z |
lftroq |
Race (IOI11_race) |
C++14 |
|
382 ms |
108700 KB |
/*
:-=-
:%@@@@@@@@@=
.#@@@@@%@%@@@@@@=
-@@@@@@@@@@@@@@@@@#
.+@@@@@@@@@@@@@@@@@@@@.
#@@@@@@@@@@@@@@@@@@@@@%
.*@@@@@@@@@@@@@@@@@@@@@@@= / ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄\
.@@@@@@@@@@@@@@@@@@@@@@@@# | lftroq ♥ |
+@@@@@@@@@@@%%@@@@@@@@@@@@- \_________/
.%@@@@@@@@@@%##%@@@@@@@@@@@# //
-@@@@@@@@%%%%%%%%%@@@@@@@@@@:
-+- =@@@@@%##%#%##**+#@@@@@@@@@@-
.+++.%@@@%##%%%%%%%#**+##%%@@@@@@+
+=*%@@@#*###%%#=--+=+*##%@@@@@@%.
:*+%@@*+**##*=======+***#@@@@@@@:
=+++**%@###*=++=-==++**#@@@@@@@:
.**===*%@@@##+=**#*==***@@@@@@@@@:
:+++=+*+%%@@%#==+*%#*+=++@@@@@@@@%
.**#*+*+**+%#+=---=***+==*@@@@@@@:
:**#*+=+**@%##*%#++++--=++#@@@@@@@+-::.
=%**###**#@@%*=*%%%%%*==++++%@@@@@@#=-----.
.%@@%***###@@@%*++%%%#*===+=++++%@@@@%*=-----=.
=**##+=+##@@@@=+%+=***#%@#+**++++%@@%+=-------=:
.++===++====@@@@+--==-=#%%%%+++*++++#%+=------==+=.
-++--=++-:::::=#@#----+--*%%*+**+++++++==-----===--+=
:*+=--++-::::::--=-----==-=%==+%%***++=---=---===-=++:
:*+--+=-::::::::---:----+=-=++##***===-::::-+----=*+:
.=--:::.:::-=-::---::--------++--=====-::::--:-==++
:=::::::--::::::--=+-:--++++==++--==:::-:::----==+=
*-:::::::.....:-++++++++++++++=+=---::::===-:------
:+:--:......:-+++++++++++++++++====---:--=-=----:-:=.
:==--:::.:=+++++++++++++++++++++-::===-:-===-----=--:
.+=--:::-:=+++++==++++++++++++++=--:.:-===+-------+=-.
.+==-----::-+++-:+++=====+++++++=--=======--:----==+=.
:+===-----------:-++====+++++++++=--==--+-:------==-::
+=====-::----+-::-+====+++++++++++=---==:-===:-==-==.
:+===========+-::::-----+++++++++++*=--======-=+=-=.
.=========++=-::::::----:::-++++++*+=+======+++==.
.=========-::::::-----:::=+++++**+=+**====-:. .
*======-::::::::-:-----++++++++==++++++-
#======-:::::::::-------++++++++====+++=
=======-:::::::::----:::=+++++++=====+++
=====---:::::::::::------=++++++===+==++=
:===-:--:::::::::::-------+++++++===++=++
.===-:--:::::::::::::-----=+++++====++===.
.+=-::--::::::::::::-:-----++++++====++=+:
.=-:::--::::::::::::-------=+++++===-----+=
.=-:::--:::::::::::---------=++++==-----==+=.
.=-:::---:::::::::::---------+++===-----===++.
.=::::---:::::::-:-----------=++==-:-----===+-
.--:::---:::::::--------------=+=----==--===+-
.=::::---::::::::::-------===--==-------=--==:
.=--::--::::----:---:::::-:----:::-----======-
.=---:--:::---::::::--------------------==++++
*/
#include <bits/stdc++.h>
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MOD 1000000007LL
#define MOD2 998244353LL
#define endl '\n'
#define PI acos(-1)
#define INFINITE 2147483647LL
#define INFINITE2 9223372036854775807
#define llll pair<ll,ll>
#define ldld pair<ld,ld>
#define fi first
#define se second
#define sqrt sqrtl
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using namespace std;
ll ans=INFINITE,nn,kk;
vector<llll> graph[200005];
map<ll,ll> m[200005];
ll h[200005],c[200005];
void dfs(int u,int p)
{
ll t=kk+2*c[u];
for(int i=0;i<(int)graph[u].size();i++)
{
ll v=graph[u][i].fi,w=graph[u][i].se;
if(v==p) continue;
h[v]=h[u]+1;
c[v]=c[u]+w;
m[v][c[v]]=h[v];
dfs(v,u);
if(m[v].size()>m[u].size()) swap(m[u],m[v]);
for(map<ll,ll>::iterator it=m[v].begin();it!=m[v].end();it++) if(m[u].find(t-it->fi)!=m[u].end()) ans=min(ans,m[u][t-it->fi]+it->se-2*h[u]);
for(map<ll,ll>::iterator it=m[v].begin();it!=m[v].end();it++) if(m[u].find(it->fi)!=m[u].end()) m[u][it->fi]=min(m[u][it->fi],it->se); else m[u][it->fi]=it->se;
}
}
int best_path(int n,int k,int edges[][2],int weights[])
{
nn=n;kk=k;
for(int i=0;i<n;i++)
{
ll u,v,w;
u=edges[i][0];
v=edges[i][1];
u++;v++;
w=weights[i];
graph[u].push_back({v,w});
graph[v].push_back({u,w});
}
dfs(1,1);
if(ans==INFINITE) ans=-1;
if(k==1) ans=0;
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
19288 KB |
Output is correct |
2 |
Correct |
4 ms |
19292 KB |
Output is correct |
3 |
Correct |
4 ms |
19244 KB |
Output is correct |
4 |
Correct |
4 ms |
19036 KB |
Output is correct |
5 |
Correct |
5 ms |
19292 KB |
Output is correct |
6 |
Correct |
4 ms |
19292 KB |
Output is correct |
7 |
Correct |
4 ms |
19216 KB |
Output is correct |
8 |
Correct |
4 ms |
19544 KB |
Output is correct |
9 |
Correct |
5 ms |
19292 KB |
Output is correct |
10 |
Correct |
4 ms |
19296 KB |
Output is correct |
11 |
Correct |
4 ms |
19292 KB |
Output is correct |
12 |
Correct |
4 ms |
19292 KB |
Output is correct |
13 |
Correct |
4 ms |
19292 KB |
Output is correct |
14 |
Correct |
4 ms |
19292 KB |
Output is correct |
15 |
Correct |
4 ms |
19288 KB |
Output is correct |
16 |
Correct |
4 ms |
19288 KB |
Output is correct |
17 |
Correct |
4 ms |
19292 KB |
Output is correct |
18 |
Correct |
4 ms |
19292 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
19288 KB |
Output is correct |
2 |
Correct |
4 ms |
19292 KB |
Output is correct |
3 |
Correct |
4 ms |
19244 KB |
Output is correct |
4 |
Correct |
4 ms |
19036 KB |
Output is correct |
5 |
Correct |
5 ms |
19292 KB |
Output is correct |
6 |
Correct |
4 ms |
19292 KB |
Output is correct |
7 |
Correct |
4 ms |
19216 KB |
Output is correct |
8 |
Correct |
4 ms |
19544 KB |
Output is correct |
9 |
Correct |
5 ms |
19292 KB |
Output is correct |
10 |
Correct |
4 ms |
19296 KB |
Output is correct |
11 |
Correct |
4 ms |
19292 KB |
Output is correct |
12 |
Correct |
4 ms |
19292 KB |
Output is correct |
13 |
Correct |
4 ms |
19292 KB |
Output is correct |
14 |
Correct |
4 ms |
19292 KB |
Output is correct |
15 |
Correct |
4 ms |
19288 KB |
Output is correct |
16 |
Correct |
4 ms |
19288 KB |
Output is correct |
17 |
Correct |
4 ms |
19292 KB |
Output is correct |
18 |
Correct |
4 ms |
19292 KB |
Output is correct |
19 |
Correct |
4 ms |
19036 KB |
Output is correct |
20 |
Correct |
4 ms |
19288 KB |
Output is correct |
21 |
Correct |
5 ms |
19292 KB |
Output is correct |
22 |
Correct |
5 ms |
19544 KB |
Output is correct |
23 |
Correct |
6 ms |
19548 KB |
Output is correct |
24 |
Correct |
5 ms |
19516 KB |
Output is correct |
25 |
Correct |
5 ms |
19548 KB |
Output is correct |
26 |
Correct |
5 ms |
19544 KB |
Output is correct |
27 |
Correct |
5 ms |
19288 KB |
Output is correct |
28 |
Correct |
6 ms |
19548 KB |
Output is correct |
29 |
Correct |
5 ms |
19548 KB |
Output is correct |
30 |
Correct |
5 ms |
19544 KB |
Output is correct |
31 |
Correct |
7 ms |
19548 KB |
Output is correct |
32 |
Correct |
5 ms |
19548 KB |
Output is correct |
33 |
Correct |
6 ms |
19504 KB |
Output is correct |
34 |
Correct |
5 ms |
19292 KB |
Output is correct |
35 |
Correct |
5 ms |
19292 KB |
Output is correct |
36 |
Correct |
5 ms |
19292 KB |
Output is correct |
37 |
Correct |
5 ms |
19292 KB |
Output is correct |
38 |
Correct |
5 ms |
19292 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
19288 KB |
Output is correct |
2 |
Correct |
4 ms |
19292 KB |
Output is correct |
3 |
Correct |
4 ms |
19244 KB |
Output is correct |
4 |
Correct |
4 ms |
19036 KB |
Output is correct |
5 |
Correct |
5 ms |
19292 KB |
Output is correct |
6 |
Correct |
4 ms |
19292 KB |
Output is correct |
7 |
Correct |
4 ms |
19216 KB |
Output is correct |
8 |
Correct |
4 ms |
19544 KB |
Output is correct |
9 |
Correct |
5 ms |
19292 KB |
Output is correct |
10 |
Correct |
4 ms |
19296 KB |
Output is correct |
11 |
Correct |
4 ms |
19292 KB |
Output is correct |
12 |
Correct |
4 ms |
19292 KB |
Output is correct |
13 |
Correct |
4 ms |
19292 KB |
Output is correct |
14 |
Correct |
4 ms |
19292 KB |
Output is correct |
15 |
Correct |
4 ms |
19288 KB |
Output is correct |
16 |
Correct |
4 ms |
19288 KB |
Output is correct |
17 |
Correct |
4 ms |
19292 KB |
Output is correct |
18 |
Correct |
4 ms |
19292 KB |
Output is correct |
19 |
Correct |
102 ms |
43344 KB |
Output is correct |
20 |
Correct |
117 ms |
44300 KB |
Output is correct |
21 |
Correct |
95 ms |
43668 KB |
Output is correct |
22 |
Correct |
104 ms |
43880 KB |
Output is correct |
23 |
Correct |
141 ms |
56832 KB |
Output is correct |
24 |
Correct |
107 ms |
46656 KB |
Output is correct |
25 |
Correct |
87 ms |
43604 KB |
Output is correct |
26 |
Correct |
52 ms |
49864 KB |
Output is correct |
27 |
Correct |
155 ms |
54844 KB |
Output is correct |
28 |
Correct |
258 ms |
90820 KB |
Output is correct |
29 |
Correct |
255 ms |
89604 KB |
Output is correct |
30 |
Correct |
162 ms |
55380 KB |
Output is correct |
31 |
Correct |
170 ms |
55664 KB |
Output is correct |
32 |
Correct |
207 ms |
55268 KB |
Output is correct |
33 |
Correct |
205 ms |
60500 KB |
Output is correct |
34 |
Correct |
280 ms |
92756 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
19288 KB |
Output is correct |
2 |
Correct |
4 ms |
19292 KB |
Output is correct |
3 |
Correct |
4 ms |
19244 KB |
Output is correct |
4 |
Correct |
4 ms |
19036 KB |
Output is correct |
5 |
Correct |
5 ms |
19292 KB |
Output is correct |
6 |
Correct |
4 ms |
19292 KB |
Output is correct |
7 |
Correct |
4 ms |
19216 KB |
Output is correct |
8 |
Correct |
4 ms |
19544 KB |
Output is correct |
9 |
Correct |
5 ms |
19292 KB |
Output is correct |
10 |
Correct |
4 ms |
19296 KB |
Output is correct |
11 |
Correct |
4 ms |
19292 KB |
Output is correct |
12 |
Correct |
4 ms |
19292 KB |
Output is correct |
13 |
Correct |
4 ms |
19292 KB |
Output is correct |
14 |
Correct |
4 ms |
19292 KB |
Output is correct |
15 |
Correct |
4 ms |
19288 KB |
Output is correct |
16 |
Correct |
4 ms |
19288 KB |
Output is correct |
17 |
Correct |
4 ms |
19292 KB |
Output is correct |
18 |
Correct |
4 ms |
19292 KB |
Output is correct |
19 |
Correct |
4 ms |
19036 KB |
Output is correct |
20 |
Correct |
4 ms |
19288 KB |
Output is correct |
21 |
Correct |
5 ms |
19292 KB |
Output is correct |
22 |
Correct |
5 ms |
19544 KB |
Output is correct |
23 |
Correct |
6 ms |
19548 KB |
Output is correct |
24 |
Correct |
5 ms |
19516 KB |
Output is correct |
25 |
Correct |
5 ms |
19548 KB |
Output is correct |
26 |
Correct |
5 ms |
19544 KB |
Output is correct |
27 |
Correct |
5 ms |
19288 KB |
Output is correct |
28 |
Correct |
6 ms |
19548 KB |
Output is correct |
29 |
Correct |
5 ms |
19548 KB |
Output is correct |
30 |
Correct |
5 ms |
19544 KB |
Output is correct |
31 |
Correct |
7 ms |
19548 KB |
Output is correct |
32 |
Correct |
5 ms |
19548 KB |
Output is correct |
33 |
Correct |
6 ms |
19504 KB |
Output is correct |
34 |
Correct |
5 ms |
19292 KB |
Output is correct |
35 |
Correct |
5 ms |
19292 KB |
Output is correct |
36 |
Correct |
5 ms |
19292 KB |
Output is correct |
37 |
Correct |
5 ms |
19292 KB |
Output is correct |
38 |
Correct |
5 ms |
19292 KB |
Output is correct |
39 |
Correct |
102 ms |
43344 KB |
Output is correct |
40 |
Correct |
117 ms |
44300 KB |
Output is correct |
41 |
Correct |
95 ms |
43668 KB |
Output is correct |
42 |
Correct |
104 ms |
43880 KB |
Output is correct |
43 |
Correct |
141 ms |
56832 KB |
Output is correct |
44 |
Correct |
107 ms |
46656 KB |
Output is correct |
45 |
Correct |
87 ms |
43604 KB |
Output is correct |
46 |
Correct |
52 ms |
49864 KB |
Output is correct |
47 |
Correct |
155 ms |
54844 KB |
Output is correct |
48 |
Correct |
258 ms |
90820 KB |
Output is correct |
49 |
Correct |
255 ms |
89604 KB |
Output is correct |
50 |
Correct |
162 ms |
55380 KB |
Output is correct |
51 |
Correct |
170 ms |
55664 KB |
Output is correct |
52 |
Correct |
207 ms |
55268 KB |
Output is correct |
53 |
Correct |
205 ms |
60500 KB |
Output is correct |
54 |
Correct |
280 ms |
92756 KB |
Output is correct |
55 |
Correct |
15 ms |
22360 KB |
Output is correct |
56 |
Correct |
10 ms |
21084 KB |
Output is correct |
57 |
Correct |
60 ms |
40856 KB |
Output is correct |
58 |
Correct |
43 ms |
34500 KB |
Output is correct |
59 |
Correct |
73 ms |
56236 KB |
Output is correct |
60 |
Correct |
249 ms |
89928 KB |
Output is correct |
61 |
Correct |
189 ms |
58368 KB |
Output is correct |
62 |
Correct |
151 ms |
55192 KB |
Output is correct |
63 |
Correct |
200 ms |
55320 KB |
Output is correct |
64 |
Correct |
382 ms |
108700 KB |
Output is correct |
65 |
Correct |
363 ms |
108360 KB |
Output is correct |
66 |
Correct |
276 ms |
84656 KB |
Output is correct |
67 |
Correct |
150 ms |
49292 KB |
Output is correct |
68 |
Correct |
296 ms |
71252 KB |
Output is correct |
69 |
Correct |
330 ms |
73820 KB |
Output is correct |
70 |
Correct |
285 ms |
69556 KB |
Output is correct |