//apig's property
//Happiness can be found, even in the darkest of times, if one only remembers to turn on the light
//El Pueblo Unido Jamas Sera Vencido
//The saddest thing about betrayal? is that it never comes from your enemies
//Do or do not... there is no try
//Billions of bilious blue blistering barnacles in a thundering typhoon!
#include "swap.h"
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0) , cin.tie(0) , cout.tie(0)
#define F first
#define S second
#define pb push_back
#define vll vector< ll >
#define vi vector< int >
#define pll pair< ll , ll >
#define pi pair< int , int >
#define all(s) s.begin() , s.end()
#define sz(s) s.size()
#define str string
#define md ((s + e) / 2)
#define mid ((l + r) / 2)
#define msdp(dp) memset(dp , -1 , sizeof dp)
#define mscl(dp) memset(dp , 0 , sizeof dp)
#define C continue
#define R return
#define B break
#define lx node * 2
#define rx node * 2 + 1
#define br(o) o ; break
#define co(o) o ; continue
using namespace std;
typedef int ll;
ll q, dp[105][100005], a[555555] , b[555555], k, l, m, n, o, p;
map < ll , ll > mp;
vll adj[555555];
const ll mod = 1e9+7;
str s;
pll tree[555555] ;
pll mrg(pll a , pll b){
ll o1 = a.F , o2 = a.S , p1 = b.F , p2 = b.S ;
R { min(o1 , p1) , min( { max(p1 , o1) , p2 , o2 } ) } ;
}
void build(ll s , ll e , ll node){
if(s == e){
tree[node] = {a[s] , mod};
R ;
}
build(s , md , lx) , build(md + 1 , e , rx) ;
tree[node] = mrg(tree[lx] , tree[rx]) ;
}
pll query(ll s , ll e , ll node , ll l , ll r){
if(s > r || e < l || l > r)R {mod , mod} ;
if(l <= s && e <= r)R tree[node] ;
R mrg(query(s , md , lx , l , r) , query(md + 1 , e , rx , l , r) );
}
void init(int N, int M, vector<int> U, vector<int> V, vector<int> W) {
n = N ;
for(ll i = 0 ; i < M ; i++){
a[V[i]] = W[i] ;
}
build(1 , n - 1 , 1) ;
}
int getMinimumFuelCapacity(int X, int Y) {
o = X , p = Y ;
if(o > p)swap(o , p) ;
ll ans = -1 ;
if(n <= 3)R ans ;
pll o1 = query(1 , n - 1 , 1 , 1 , o - 1) , o2 = query(1 , n - 1 , 1 , o + 1 , p - 1) , o3 = query(1 , n - 1 , 1 , p + 1 , n - 1) ;
pll res = mrg(mrg(o1 , o2) , o3) ;
if(!o){
ans = max ( { a[p] , res.F , res.S } ) ;
}
else {
ans = max ( { a[o] , a[p] , res.F } ) ;
}
R ans ;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
13260 KB |
Output is correct |
2 |
Correct |
9 ms |
13288 KB |
Output is correct |
3 |
Correct |
10 ms |
13264 KB |
Output is correct |
4 |
Incorrect |
8 ms |
13368 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
13260 KB |
Output is correct |
2 |
Correct |
9 ms |
13288 KB |
Output is correct |
3 |
Correct |
310 ms |
20908 KB |
Output is correct |
4 |
Correct |
305 ms |
24768 KB |
Output is correct |
5 |
Correct |
325 ms |
25148 KB |
Output is correct |
6 |
Correct |
303 ms |
24708 KB |
Output is correct |
7 |
Correct |
325 ms |
25128 KB |
Output is correct |
8 |
Correct |
312 ms |
24948 KB |
Output is correct |
9 |
Correct |
319 ms |
24900 KB |
Output is correct |
10 |
Correct |
320 ms |
24980 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
13260 KB |
Output is correct |
2 |
Correct |
9 ms |
13288 KB |
Output is correct |
3 |
Correct |
10 ms |
13264 KB |
Output is correct |
4 |
Incorrect |
8 ms |
13368 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
13260 KB |
Output is correct |
2 |
Correct |
9 ms |
13288 KB |
Output is correct |
3 |
Correct |
10 ms |
13264 KB |
Output is correct |
4 |
Incorrect |
8 ms |
13368 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
13260 KB |
Output is correct |
2 |
Correct |
9 ms |
13288 KB |
Output is correct |
3 |
Correct |
10 ms |
13264 KB |
Output is correct |
4 |
Incorrect |
8 ms |
13368 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
13260 KB |
Output is correct |
2 |
Correct |
9 ms |
13288 KB |
Output is correct |
3 |
Correct |
10 ms |
13264 KB |
Output is correct |
4 |
Incorrect |
8 ms |
13368 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |