# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
538263 |
2022-03-16T12:49:36 Z |
myrcella |
Race (IOI11_race) |
C++17 |
|
463 ms |
76064 KB |
//by szh
#include "race.h"
#include<bits/stdc++.h>
using namespace std;
/*
#define MAX_N 500000
static int N, K;
static int H[MAX_N][2];
static int L[MAX_N];
static int solution;
inline
void my_assert(int e) {if (!e) abort();}
void read_input()
{
int i;
my_assert(2==scanf("%d %d",&N,&K));
for(i=0; i<N-1; i++)
my_assert(3==scanf("%d %d %d",&H[i][0],&H[i][1],&L[i]));
my_assert(1==scanf("%d",&solution));
}*/
#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pb push_back
#define debug(x) cerr<<#x<<"="<<x<<endl
#define pq priority_queue
#define inf 0x3f
#define rep(i,a,b) for (int i=a;i<(b);i++)
#define MP make_pair
#define SZ(x) (int(x.size()))
#define ll long long
#define mod 1000000007
#define ALL(x) x.begin(),x.end()
void inc(int &a,int b) {a=(a+b)%mod;}
void dec(int &a,int b) {a=(a-b+mod)%mod;}
int lowbit(int x) {return x&(-x);}
ll p0w(ll base,ll p) {ll ret=1;while(p>0){if (p%2ll==1ll) ret=ret*base%mod;base=base*base%mod;p/=2ll;}return ret;}
const int maxn = 2e5+10;
vector <pii> edge[maxn];
int ans = mod;
ll len;
map <ll,int> dfs(int u,int fa,int dep,ll depl) {
map<ll,int> ret;
for (pii v:edge[u]) {
if (v.fi==fa) continue;
map<ll,int> tmp = dfs(v.fi,u,dep+1,depl+(ll)v.se);
if (SZ(ret)<SZ(tmp)) swap(ret,tmp);
// debug(SZ(tmp)), debug(SZ(ret)),debug(u);
for (auto it:tmp) {
if (ret.find(2*depl+len-it.fi)!=ret.end()) ans = min(ans,ret[2*depl+len-it.fi]+it.se-2*dep);
}
for (auto it:tmp) {
if (ret.find(it.fi)!=ret.end()) ret[it.fi] = min(it.se,ret[it.fi]);
else ret[it.fi] = it.se;
}
}
ret[depl] = dep;
if (ret.find(depl+len)!=ret.end()) ans = min (ans,ret[depl+len]-dep);
return ret;
}
int best_path(int N, int K, int H[][2], int L[]) {
len = K;
rep(i,0,N-1) {
edge[H[i][0]].pb(MP(H[i][1],L[i]));
edge[H[i][1]].pb({H[i][0],L[i]});
}
dfs(0,-1,0,0);
if (ans == mod) return -1;
else return ans;
}
/*
int main()
{
int ans;
read_input();
ans = best_path(N,K,H,L);
if(ans==solution)
printf("Correct.\n");
else
printf("Incorrect. Returned %d, Expected %d.\n",ans,solution);
return 0;
}
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
4948 KB |
Output is correct |
2 |
Correct |
3 ms |
4948 KB |
Output is correct |
3 |
Correct |
3 ms |
4948 KB |
Output is correct |
4 |
Correct |
3 ms |
4948 KB |
Output is correct |
5 |
Correct |
3 ms |
5008 KB |
Output is correct |
6 |
Correct |
3 ms |
4996 KB |
Output is correct |
7 |
Correct |
3 ms |
4948 KB |
Output is correct |
8 |
Correct |
3 ms |
4948 KB |
Output is correct |
9 |
Correct |
3 ms |
4948 KB |
Output is correct |
10 |
Correct |
4 ms |
4948 KB |
Output is correct |
11 |
Correct |
3 ms |
4948 KB |
Output is correct |
12 |
Correct |
3 ms |
4948 KB |
Output is correct |
13 |
Correct |
4 ms |
4984 KB |
Output is correct |
14 |
Correct |
3 ms |
5040 KB |
Output is correct |
15 |
Correct |
3 ms |
4948 KB |
Output is correct |
16 |
Correct |
3 ms |
4948 KB |
Output is correct |
17 |
Correct |
3 ms |
4948 KB |
Output is correct |
18 |
Correct |
3 ms |
5004 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
4948 KB |
Output is correct |
2 |
Correct |
3 ms |
4948 KB |
Output is correct |
3 |
Correct |
3 ms |
4948 KB |
Output is correct |
4 |
Correct |
3 ms |
4948 KB |
Output is correct |
5 |
Correct |
3 ms |
5008 KB |
Output is correct |
6 |
Correct |
3 ms |
4996 KB |
Output is correct |
7 |
Correct |
3 ms |
4948 KB |
Output is correct |
8 |
Correct |
3 ms |
4948 KB |
Output is correct |
9 |
Correct |
3 ms |
4948 KB |
Output is correct |
10 |
Correct |
4 ms |
4948 KB |
Output is correct |
11 |
Correct |
3 ms |
4948 KB |
Output is correct |
12 |
Correct |
3 ms |
4948 KB |
Output is correct |
13 |
Correct |
4 ms |
4984 KB |
Output is correct |
14 |
Correct |
3 ms |
5040 KB |
Output is correct |
15 |
Correct |
3 ms |
4948 KB |
Output is correct |
16 |
Correct |
3 ms |
4948 KB |
Output is correct |
17 |
Correct |
3 ms |
4948 KB |
Output is correct |
18 |
Correct |
3 ms |
5004 KB |
Output is correct |
19 |
Correct |
3 ms |
5004 KB |
Output is correct |
20 |
Correct |
3 ms |
4948 KB |
Output is correct |
21 |
Correct |
4 ms |
5076 KB |
Output is correct |
22 |
Correct |
4 ms |
5084 KB |
Output is correct |
23 |
Correct |
5 ms |
5076 KB |
Output is correct |
24 |
Correct |
5 ms |
5020 KB |
Output is correct |
25 |
Correct |
4 ms |
5076 KB |
Output is correct |
26 |
Correct |
4 ms |
5076 KB |
Output is correct |
27 |
Correct |
3 ms |
5076 KB |
Output is correct |
28 |
Correct |
4 ms |
5076 KB |
Output is correct |
29 |
Correct |
4 ms |
5076 KB |
Output is correct |
30 |
Correct |
4 ms |
5144 KB |
Output is correct |
31 |
Correct |
4 ms |
5076 KB |
Output is correct |
32 |
Correct |
4 ms |
5076 KB |
Output is correct |
33 |
Correct |
4 ms |
5076 KB |
Output is correct |
34 |
Correct |
4 ms |
5148 KB |
Output is correct |
35 |
Correct |
4 ms |
5076 KB |
Output is correct |
36 |
Correct |
4 ms |
5204 KB |
Output is correct |
37 |
Correct |
5 ms |
5076 KB |
Output is correct |
38 |
Correct |
4 ms |
5076 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
4948 KB |
Output is correct |
2 |
Correct |
3 ms |
4948 KB |
Output is correct |
3 |
Correct |
3 ms |
4948 KB |
Output is correct |
4 |
Correct |
3 ms |
4948 KB |
Output is correct |
5 |
Correct |
3 ms |
5008 KB |
Output is correct |
6 |
Correct |
3 ms |
4996 KB |
Output is correct |
7 |
Correct |
3 ms |
4948 KB |
Output is correct |
8 |
Correct |
3 ms |
4948 KB |
Output is correct |
9 |
Correct |
3 ms |
4948 KB |
Output is correct |
10 |
Correct |
4 ms |
4948 KB |
Output is correct |
11 |
Correct |
3 ms |
4948 KB |
Output is correct |
12 |
Correct |
3 ms |
4948 KB |
Output is correct |
13 |
Correct |
4 ms |
4984 KB |
Output is correct |
14 |
Correct |
3 ms |
5040 KB |
Output is correct |
15 |
Correct |
3 ms |
4948 KB |
Output is correct |
16 |
Correct |
3 ms |
4948 KB |
Output is correct |
17 |
Correct |
3 ms |
4948 KB |
Output is correct |
18 |
Correct |
3 ms |
5004 KB |
Output is correct |
19 |
Correct |
97 ms |
11212 KB |
Output is correct |
20 |
Correct |
95 ms |
11400 KB |
Output is correct |
21 |
Correct |
93 ms |
11260 KB |
Output is correct |
22 |
Correct |
119 ms |
11272 KB |
Output is correct |
23 |
Correct |
143 ms |
11792 KB |
Output is correct |
24 |
Correct |
86 ms |
11552 KB |
Output is correct |
25 |
Correct |
66 ms |
23700 KB |
Output is correct |
26 |
Correct |
54 ms |
34084 KB |
Output is correct |
27 |
Correct |
197 ms |
18160 KB |
Output is correct |
28 |
Correct |
212 ms |
76064 KB |
Output is correct |
29 |
Correct |
227 ms |
73420 KB |
Output is correct |
30 |
Correct |
177 ms |
18192 KB |
Output is correct |
31 |
Correct |
185 ms |
18168 KB |
Output is correct |
32 |
Correct |
235 ms |
18260 KB |
Output is correct |
33 |
Correct |
173 ms |
17760 KB |
Output is correct |
34 |
Correct |
340 ms |
31244 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
4948 KB |
Output is correct |
2 |
Correct |
3 ms |
4948 KB |
Output is correct |
3 |
Correct |
3 ms |
4948 KB |
Output is correct |
4 |
Correct |
3 ms |
4948 KB |
Output is correct |
5 |
Correct |
3 ms |
5008 KB |
Output is correct |
6 |
Correct |
3 ms |
4996 KB |
Output is correct |
7 |
Correct |
3 ms |
4948 KB |
Output is correct |
8 |
Correct |
3 ms |
4948 KB |
Output is correct |
9 |
Correct |
3 ms |
4948 KB |
Output is correct |
10 |
Correct |
4 ms |
4948 KB |
Output is correct |
11 |
Correct |
3 ms |
4948 KB |
Output is correct |
12 |
Correct |
3 ms |
4948 KB |
Output is correct |
13 |
Correct |
4 ms |
4984 KB |
Output is correct |
14 |
Correct |
3 ms |
5040 KB |
Output is correct |
15 |
Correct |
3 ms |
4948 KB |
Output is correct |
16 |
Correct |
3 ms |
4948 KB |
Output is correct |
17 |
Correct |
3 ms |
4948 KB |
Output is correct |
18 |
Correct |
3 ms |
5004 KB |
Output is correct |
19 |
Correct |
3 ms |
5004 KB |
Output is correct |
20 |
Correct |
3 ms |
4948 KB |
Output is correct |
21 |
Correct |
4 ms |
5076 KB |
Output is correct |
22 |
Correct |
4 ms |
5084 KB |
Output is correct |
23 |
Correct |
5 ms |
5076 KB |
Output is correct |
24 |
Correct |
5 ms |
5020 KB |
Output is correct |
25 |
Correct |
4 ms |
5076 KB |
Output is correct |
26 |
Correct |
4 ms |
5076 KB |
Output is correct |
27 |
Correct |
3 ms |
5076 KB |
Output is correct |
28 |
Correct |
4 ms |
5076 KB |
Output is correct |
29 |
Correct |
4 ms |
5076 KB |
Output is correct |
30 |
Correct |
4 ms |
5144 KB |
Output is correct |
31 |
Correct |
4 ms |
5076 KB |
Output is correct |
32 |
Correct |
4 ms |
5076 KB |
Output is correct |
33 |
Correct |
4 ms |
5076 KB |
Output is correct |
34 |
Correct |
4 ms |
5148 KB |
Output is correct |
35 |
Correct |
4 ms |
5076 KB |
Output is correct |
36 |
Correct |
4 ms |
5204 KB |
Output is correct |
37 |
Correct |
5 ms |
5076 KB |
Output is correct |
38 |
Correct |
4 ms |
5076 KB |
Output is correct |
39 |
Correct |
97 ms |
11212 KB |
Output is correct |
40 |
Correct |
95 ms |
11400 KB |
Output is correct |
41 |
Correct |
93 ms |
11260 KB |
Output is correct |
42 |
Correct |
119 ms |
11272 KB |
Output is correct |
43 |
Correct |
143 ms |
11792 KB |
Output is correct |
44 |
Correct |
86 ms |
11552 KB |
Output is correct |
45 |
Correct |
66 ms |
23700 KB |
Output is correct |
46 |
Correct |
54 ms |
34084 KB |
Output is correct |
47 |
Correct |
197 ms |
18160 KB |
Output is correct |
48 |
Correct |
212 ms |
76064 KB |
Output is correct |
49 |
Correct |
227 ms |
73420 KB |
Output is correct |
50 |
Correct |
177 ms |
18192 KB |
Output is correct |
51 |
Correct |
185 ms |
18168 KB |
Output is correct |
52 |
Correct |
235 ms |
18260 KB |
Output is correct |
53 |
Correct |
173 ms |
17760 KB |
Output is correct |
54 |
Correct |
340 ms |
31244 KB |
Output is correct |
55 |
Correct |
15 ms |
5972 KB |
Output is correct |
56 |
Correct |
9 ms |
5588 KB |
Output is correct |
57 |
Correct |
57 ms |
11460 KB |
Output is correct |
58 |
Correct |
48 ms |
11204 KB |
Output is correct |
59 |
Correct |
77 ms |
40356 KB |
Output is correct |
60 |
Correct |
193 ms |
74224 KB |
Output is correct |
61 |
Correct |
212 ms |
19900 KB |
Output is correct |
62 |
Correct |
213 ms |
18156 KB |
Output is correct |
63 |
Correct |
178 ms |
18304 KB |
Output is correct |
64 |
Correct |
463 ms |
26932 KB |
Output is correct |
65 |
Correct |
407 ms |
31328 KB |
Output is correct |
66 |
Correct |
223 ms |
67920 KB |
Output is correct |
67 |
Correct |
144 ms |
18624 KB |
Output is correct |
68 |
Correct |
313 ms |
29312 KB |
Output is correct |
69 |
Correct |
353 ms |
33868 KB |
Output is correct |
70 |
Correct |
257 ms |
28432 KB |
Output is correct |