제출 #1349002

#제출 시각아이디문제언어결과실행 시간메모리
1349002yyc000123자매 도시 (APIO20_swap)C++20
0 / 100
185 ms10624 KiB
#include<bits/stdc++.h>
using namespace std ;
const int N = 1e5+5 ;
const int M = 2e5+5 ;
multiset<int> mst ;
int n , m , wei[N] ;

void init(int n1 , int m1 , vector<int> u , vector<int> v , vector<int> w){
    n = n1 , m = m1 ;
    for(int i=0 ; i<m ; i++){
        wei[v[i]]=w[i] ;
        mst.insert(w[i]) ;
    }
}

int getMinimumFuelCapacity(int x , int y){
    if(x==0){
        mst.erase(mst.find(wei[y])) ;
        int temp = wei[y] ;
        if(!mst.empty()) temp = max(temp,*mst.begin()) ;
        else temp = -1 ;
        if(n<=3) temp = -1 ;
        mst.insert(wei[y]) ;
        return temp ;
    }
    mst.erase(mst.find(wei[x])) ;
    mst.erase(mst.find(wei[y])) ;
    int temp = max(wei[x],wei[y]) ;
    if(!mst.empty()) temp = max(temp,*mst.begin()) ;
    else temp = -1 ;
    mst.insert(wei[x]) ;
    mst.insert(wei[y]) ;
    return temp ;
}

/*
int main(){
    init(3, 2, {0, 0}, {1, 2}, {5, 5}) ;
    cout << getMinimumFuelCapacity(1, 2) << '\n' ;
    return 0 ;
}
*/
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...