#pragma GCC optimize("Ofast,unroll-loops,fast-math")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll ;
#define pll pair<ll , ll >
#define all(x) (x).begin(),(x).end()
#define SZ(x) (ll)(x).size()
#define X first
#define Y second
#define mp make_pair
#define pii pair<int , int>
#define vec vector
#define file_io freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
// BIG p : 1000000000000037 , 100000000003
ll poww(ll a, ll b, ll md) {
return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}
const int maxn = 2000*100+5 ;
const ll inf = 9223372036854775807 ;
const ll mod = 1e9 + 7 ;
const int lg = 20 ;
int par[lg][maxn] , sz[maxn] , mark[maxn] , d[maxn] , flag , ans , dp[maxn] , mx[lg][maxn] , h[maxn] , mo[maxn];
vec<pair<int , pii>> e ;
vec<pii> adj[maxn] ;
void dfsdown(int v , int p){
for(auto u : adj[v]){
if(u.X != p ){
dfsdown(u.X , v) ;
dp[v] = min(dp[v] , max(dp[u.X] , u.Y)) ;
}
}
}
void dfsup(int v , int p){
for(auto u : adj[v]){
if(u.X != p){
dp[u.X] = min(dp[u.X] , max(u.Y , dp[v])) ;
dfsup(u.X , v) ;
}
}
}
void dfs(int v , int p){
for(auto u : adj[v]){
if(u.X != p){
par[0][u.X] = v ;
mx[0][u.X] = u.Y ;
for(int i = 1 ; i < lg; i ++ ){
par[i][u.X] = par[i-1][par[i-1][u.X]] ;
mx[i][u.X] = max(mx[i-1][u.X] , mx[i-1][par[i-1][u.X]]) ;
}
h[u.X] = h[v] + 1 ;
dfs(u.X , v) ;
}
}
}
int lca(int u , int v){
int res = 0 ;
if(h[u] > h[v]) swap(u , v) ;
for(int i = lg-1 ; i >= 0 ; i -- ){
if(par[i][v] != -1 && h[par[i][v]] >= h[u]){
res = max(res , mx[i][v]) ;
v = par[i][v] ;
}
}
if(u == v) return res ;
for(int i = lg -1 ; i >= 0 ; i -- ){
if(par[i][v] != par[i][u]){
res = max(res , mx[i][v]) ;
res = max(res , mx[i][u]) ;
u = par[i][u] ;
v = par[i][v] ;
}
}
res = max(res , mx[0][u]) ; res = max(res , mx[0][v]) ;
return res ;
}
int getMinimumFuelCapacity(int x , int y){
if(!flag) return -1 ;
return ans ;
}
void init(int n , int m , vec<int> A , vec<int> B , vec<int> W ){
for(int i = 0 ; i < m ; i ++ ){
d[A[i]] ++ ;
d[B[i]] ++ ;
ans = max(ans , W[i]) ;
}
flag = 1 ;
for(int i = 0 ; i < n ; i ++ ) if(d[i] != 2) flag = 0 ;
}
/*int main()
{
migmig ;
int n , m ;
cin>>n>>m ;
int u[m] , v[m] , w[m] ;
for(int i = 0 ; i < m ; i ++ ) cin>>u[i]>>v[i]>>w[i] ;
init(n , m , u , v , w) ;
int q ;
cin>>q ;
while(q--){
int U , V ;
cin>>U>>V ;
cout<<getMinimumFuelCapacity(U , V) << endl ;
}
}*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
4940 KB |
Output is correct |
2 |
Correct |
4 ms |
4940 KB |
Output is correct |
3 |
Correct |
4 ms |
4940 KB |
Output is correct |
4 |
Correct |
4 ms |
4940 KB |
Output is correct |
5 |
Correct |
4 ms |
4940 KB |
Output is correct |
6 |
Correct |
4 ms |
5032 KB |
Output is correct |
7 |
Correct |
4 ms |
4940 KB |
Output is correct |
8 |
Correct |
4 ms |
4940 KB |
Output is correct |
9 |
Correct |
31 ms |
7092 KB |
Output is correct |
10 |
Correct |
38 ms |
7620 KB |
Output is correct |
11 |
Correct |
37 ms |
7532 KB |
Output is correct |
12 |
Correct |
39 ms |
7720 KB |
Output is correct |
13 |
Correct |
39 ms |
7724 KB |
Output is correct |
14 |
Correct |
38 ms |
7224 KB |
Output is correct |
15 |
Correct |
103 ms |
9356 KB |
Output is correct |
16 |
Correct |
105 ms |
9364 KB |
Output is correct |
17 |
Correct |
106 ms |
9516 KB |
Output is correct |
18 |
Correct |
103 ms |
9480 KB |
Output is correct |
19 |
Correct |
65 ms |
10764 KB |
Output is correct |
20 |
Correct |
104 ms |
14784 KB |
Output is correct |
21 |
Correct |
109 ms |
15020 KB |
Output is correct |
22 |
Correct |
109 ms |
15276 KB |
Output is correct |
23 |
Correct |
109 ms |
15272 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
4940 KB |
Output is correct |
2 |
Correct |
4 ms |
4940 KB |
Output is correct |
3 |
Incorrect |
96 ms |
9236 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
4940 KB |
Output is correct |
2 |
Correct |
4 ms |
4940 KB |
Output is correct |
3 |
Correct |
4 ms |
4940 KB |
Output is correct |
4 |
Correct |
4 ms |
4940 KB |
Output is correct |
5 |
Correct |
4 ms |
4940 KB |
Output is correct |
6 |
Correct |
4 ms |
5032 KB |
Output is correct |
7 |
Correct |
4 ms |
4940 KB |
Output is correct |
8 |
Correct |
4 ms |
4940 KB |
Output is correct |
9 |
Incorrect |
4 ms |
4940 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
4940 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
4940 KB |
Output is correct |
2 |
Correct |
4 ms |
4940 KB |
Output is correct |
3 |
Correct |
4 ms |
4940 KB |
Output is correct |
4 |
Correct |
4 ms |
4940 KB |
Output is correct |
5 |
Correct |
4 ms |
4940 KB |
Output is correct |
6 |
Correct |
4 ms |
5032 KB |
Output is correct |
7 |
Correct |
4 ms |
4940 KB |
Output is correct |
8 |
Correct |
4 ms |
4940 KB |
Output is correct |
9 |
Correct |
31 ms |
7092 KB |
Output is correct |
10 |
Correct |
38 ms |
7620 KB |
Output is correct |
11 |
Correct |
37 ms |
7532 KB |
Output is correct |
12 |
Correct |
39 ms |
7720 KB |
Output is correct |
13 |
Correct |
39 ms |
7724 KB |
Output is correct |
14 |
Correct |
38 ms |
7224 KB |
Output is correct |
15 |
Correct |
103 ms |
9356 KB |
Output is correct |
16 |
Correct |
105 ms |
9364 KB |
Output is correct |
17 |
Correct |
106 ms |
9516 KB |
Output is correct |
18 |
Correct |
103 ms |
9480 KB |
Output is correct |
19 |
Incorrect |
96 ms |
9236 KB |
Output isn't correct |
20 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
4940 KB |
Output isn't correct |