답안 #405657

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
405657 2021-05-16T16:23:49 Z Blistering_Barnacles 자매 도시 (APIO20_swap) C++11
0 / 100
386 ms 24996 KB
//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 = a[p] * 2 + res.F * 2 + res.S * 2 ;
    }
    else {
        ans = a[o] * 2 + a[p] * 2 + res.F * 2 ;
    }
    R ans ;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 13260 KB Output is correct
2 Correct 10 ms 13260 KB Output is correct
3 Correct 9 ms 13348 KB Output is correct
4 Incorrect 9 ms 13356 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 13260 KB Output is correct
2 Correct 10 ms 13260 KB Output is correct
3 Incorrect 386 ms 24996 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 13260 KB Output is correct
2 Correct 10 ms 13260 KB Output is correct
3 Correct 9 ms 13348 KB Output is correct
4 Incorrect 9 ms 13356 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 13260 KB Output is correct
2 Correct 10 ms 13260 KB Output is correct
3 Correct 9 ms 13348 KB Output is correct
4 Incorrect 9 ms 13356 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 13260 KB Output is correct
2 Correct 10 ms 13260 KB Output is correct
3 Correct 9 ms 13348 KB Output is correct
4 Incorrect 9 ms 13356 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 13260 KB Output is correct
2 Correct 10 ms 13260 KB Output is correct
3 Correct 9 ms 13348 KB Output is correct
4 Incorrect 9 ms 13356 KB Output isn't correct
5 Halted 0 ms 0 KB -