#include<bits/stdc++.h>
#include "swap.h"
//#include "grader.cpp"
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int>vi;
typedef vector<vector<int>>vvi;
typedef vector<ll>vl;
typedef vector<vl> vvl;
typedef pair<int,int>pi;
typedef pair<ll,ll> pl;
typedef vector<pl> vpl;
typedef vector<ld> vld;
typedef pair<ld,ld> pld;
//typedef tree<ll, null_type, less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
template<typename T> ostream& operator<<(ostream& os, vector<T>& a){os<<"[";for(int i=0; i<ll(a.size()); i++){os << a[i] << ((i!=ll(a.size()-1)?" ":""));}os << "]\n"; return os;}
#define all(x) x.begin(),x.end()
#define YES out("YES")
#define NO out("NO")
#define out(x){cout << x << "\n"; return;}
#define GLHF ios_base::sync_with_stdio(false); cin.tie(NULL)
#define print(x){for(auto ait:x) cout << ait << " "; cout << "\n";}
#define pb push_back
#define umap unordered_map
vector<vector<pi>> g;
vector<bool>vis;
void init(int n, int M,vi U,vi V,vi W){
g.resize(n);
vis.resize(n);
for(int i=0; i<M; i++){
g[U[i]].pb({V[i],W[i]});
g[V[i]].pb({U[i],W[i]});
}
}
bool ans;
void dfs(int src,int par,int w){
vis[src]=1;
int cnt=0;
for(pi nbr:g[src])
if(nbr.second<=w)
cnt++;
if(cnt>2)
ans=1;
for(pi nbr:g[src]) {
if(nbr.first==par || nbr.second>w)continue;
if(vis[nbr.first])ans=1;
else dfs(nbr.first,src,w);
}
}
bool ok(int x,int y,int w){
int n=g.size();
vis.assign(n,0);
ans=0;
dfs(x,-1,w);
if(!vis[y])return 0;
return ans;
}
int getMinimumFuelCapacity(int X, int Y){
ll l=1,r=1e9+1,ans=-1;
while(l<=r){
ll m=(l+r)/2;
if(ok(X,Y,m))
ans=m,r=m-1;
else
l=m+1;
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
3 ms |
332 KB |
Output is correct |
5 |
Correct |
3 ms |
332 KB |
Output is correct |
6 |
Correct |
3 ms |
332 KB |
Output is correct |
7 |
Correct |
4 ms |
424 KB |
Output is correct |
8 |
Correct |
5 ms |
428 KB |
Output is correct |
9 |
Correct |
249 ms |
10404 KB |
Output is correct |
10 |
Correct |
674 ms |
12004 KB |
Output is correct |
11 |
Correct |
878 ms |
14268 KB |
Output is correct |
12 |
Correct |
928 ms |
14376 KB |
Output is correct |
13 |
Correct |
1325 ms |
14976 KB |
Output is correct |
14 |
Execution timed out |
2062 ms |
12316 KB |
Time limit exceeded |
15 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Execution timed out |
2069 ms |
9832 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
3 ms |
332 KB |
Output is correct |
5 |
Correct |
3 ms |
332 KB |
Output is correct |
6 |
Correct |
3 ms |
332 KB |
Output is correct |
7 |
Correct |
4 ms |
424 KB |
Output is correct |
8 |
Correct |
5 ms |
428 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
2 ms |
332 KB |
Output is correct |
11 |
Correct |
4 ms |
332 KB |
Output is correct |
12 |
Correct |
4 ms |
332 KB |
Output is correct |
13 |
Correct |
3 ms |
332 KB |
Output is correct |
14 |
Correct |
3 ms |
332 KB |
Output is correct |
15 |
Correct |
3 ms |
332 KB |
Output is correct |
16 |
Correct |
4 ms |
332 KB |
Output is correct |
17 |
Correct |
4 ms |
412 KB |
Output is correct |
18 |
Correct |
3 ms |
332 KB |
Output is correct |
19 |
Correct |
3 ms |
376 KB |
Output is correct |
20 |
Correct |
4 ms |
332 KB |
Output is correct |
21 |
Correct |
4 ms |
332 KB |
Output is correct |
22 |
Correct |
4 ms |
304 KB |
Output is correct |
23 |
Correct |
3 ms |
332 KB |
Output is correct |
24 |
Correct |
3 ms |
332 KB |
Output is correct |
25 |
Correct |
3 ms |
332 KB |
Output is correct |
26 |
Correct |
7 ms |
460 KB |
Output is correct |
27 |
Correct |
3 ms |
332 KB |
Output is correct |
28 |
Correct |
4 ms |
452 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
3 ms |
332 KB |
Output is correct |
6 |
Correct |
3 ms |
332 KB |
Output is correct |
7 |
Correct |
3 ms |
332 KB |
Output is correct |
8 |
Correct |
4 ms |
424 KB |
Output is correct |
9 |
Correct |
5 ms |
428 KB |
Output is correct |
10 |
Correct |
249 ms |
10404 KB |
Output is correct |
11 |
Correct |
674 ms |
12004 KB |
Output is correct |
12 |
Correct |
878 ms |
14268 KB |
Output is correct |
13 |
Correct |
928 ms |
14376 KB |
Output is correct |
14 |
Correct |
1325 ms |
14976 KB |
Output is correct |
15 |
Correct |
2 ms |
332 KB |
Output is correct |
16 |
Correct |
4 ms |
332 KB |
Output is correct |
17 |
Correct |
4 ms |
332 KB |
Output is correct |
18 |
Correct |
3 ms |
332 KB |
Output is correct |
19 |
Correct |
3 ms |
332 KB |
Output is correct |
20 |
Correct |
3 ms |
332 KB |
Output is correct |
21 |
Correct |
4 ms |
332 KB |
Output is correct |
22 |
Correct |
4 ms |
412 KB |
Output is correct |
23 |
Correct |
3 ms |
332 KB |
Output is correct |
24 |
Correct |
3 ms |
376 KB |
Output is correct |
25 |
Correct |
4 ms |
332 KB |
Output is correct |
26 |
Correct |
4 ms |
332 KB |
Output is correct |
27 |
Correct |
4 ms |
304 KB |
Output is correct |
28 |
Correct |
3 ms |
332 KB |
Output is correct |
29 |
Correct |
3 ms |
332 KB |
Output is correct |
30 |
Correct |
3 ms |
332 KB |
Output is correct |
31 |
Correct |
7 ms |
460 KB |
Output is correct |
32 |
Correct |
3 ms |
332 KB |
Output is correct |
33 |
Correct |
4 ms |
452 KB |
Output is correct |
34 |
Correct |
18 ms |
1612 KB |
Output is correct |
35 |
Correct |
1237 ms |
13464 KB |
Output is correct |
36 |
Correct |
1037 ms |
11420 KB |
Output is correct |
37 |
Correct |
1044 ms |
9924 KB |
Output is correct |
38 |
Correct |
1159 ms |
9796 KB |
Output is correct |
39 |
Correct |
961 ms |
9740 KB |
Output is correct |
40 |
Correct |
1216 ms |
9168 KB |
Output is correct |
41 |
Correct |
1148 ms |
12332 KB |
Output is correct |
42 |
Correct |
1588 ms |
12720 KB |
Output is correct |
43 |
Correct |
1097 ms |
14620 KB |
Output is correct |
44 |
Correct |
495 ms |
10696 KB |
Output is correct |
45 |
Correct |
857 ms |
13828 KB |
Output is correct |
46 |
Correct |
1619 ms |
13024 KB |
Output is correct |
47 |
Correct |
1223 ms |
9924 KB |
Output is correct |
48 |
Correct |
894 ms |
10692 KB |
Output is correct |
49 |
Correct |
156 ms |
11596 KB |
Output is correct |
50 |
Correct |
154 ms |
8996 KB |
Output is correct |
51 |
Correct |
474 ms |
12116 KB |
Output is correct |
52 |
Correct |
921 ms |
16964 KB |
Output is correct |
53 |
Correct |
687 ms |
16196 KB |
Output is correct |
54 |
Execution timed out |
2068 ms |
19452 KB |
Time limit exceeded |
55 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
3 ms |
332 KB |
Output is correct |
5 |
Correct |
3 ms |
332 KB |
Output is correct |
6 |
Correct |
3 ms |
332 KB |
Output is correct |
7 |
Correct |
4 ms |
424 KB |
Output is correct |
8 |
Correct |
5 ms |
428 KB |
Output is correct |
9 |
Correct |
249 ms |
10404 KB |
Output is correct |
10 |
Correct |
674 ms |
12004 KB |
Output is correct |
11 |
Correct |
878 ms |
14268 KB |
Output is correct |
12 |
Correct |
928 ms |
14376 KB |
Output is correct |
13 |
Correct |
1325 ms |
14976 KB |
Output is correct |
14 |
Execution timed out |
2062 ms |
12316 KB |
Time limit exceeded |
15 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
3 ms |
332 KB |
Output is correct |
6 |
Correct |
3 ms |
332 KB |
Output is correct |
7 |
Correct |
3 ms |
332 KB |
Output is correct |
8 |
Correct |
4 ms |
424 KB |
Output is correct |
9 |
Correct |
5 ms |
428 KB |
Output is correct |
10 |
Correct |
249 ms |
10404 KB |
Output is correct |
11 |
Correct |
674 ms |
12004 KB |
Output is correct |
12 |
Correct |
878 ms |
14268 KB |
Output is correct |
13 |
Correct |
928 ms |
14376 KB |
Output is correct |
14 |
Correct |
1325 ms |
14976 KB |
Output is correct |
15 |
Execution timed out |
2062 ms |
12316 KB |
Time limit exceeded |
16 |
Halted |
0 ms |
0 KB |
- |