답안 #984802

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
984802 2024-05-17T05:51:35 Z Aiperiii 자매 도시 (APIO20_swap) C++14
7 / 100
233 ms 14564 KB
#include <bits/stdc++.h>
#include "swap.h"
#define ff first
#define ss second
#define pb push_back
#define all(x) x.begin(),x.end()
using namespace std;
const int N=1e5+5;
int sz[N];
multiset <int> ms;
int n;
void init(int N, int M,vector<int> U,vector<int> V,vector<int> W) {
    n=N;
    for(int i=0;i<M;i++){
        sz[V[i]]=W[i];
        ms.insert(sz[V[i]]);
    }
}

int getMinimumFuelCapacity(int X, int Y) {
    if(n<=3)return -1;
    int ans=0;
    if(sz[X]!=0)ms.erase(ms.find(sz[X]));
    if(sz[Y]!=0)ms.erase(ms.find(sz[Y]));
    if(X==0 or Y==0 ){
        ans=max({sz[X],sz[Y],*ms.begin()});
        int x=*ms.begin();
        ms.erase(ms.begin());
        ans=max(ans,*ms.begin());
        if(sz[X]!=0)ms.insert(sz[X]);
        if(sz[Y]!=0)ms.insert(sz[Y]);
        ms.insert(x);
    }
    else{
        ans=max({sz[X],sz[Y],*ms.begin()});
        ms.insert(sz[X]);
        ms.insert(sz[Y]);
    }
    return ans;
}

/*signed main(){
    ios_base::sync_with_stdio();
    cin.tie(0);cout.tie(0);
    int n,m;
    cin>>n>>m;
    vector <int> a(m),b(m),c(m);
    for(int i=0;i<m;i++){
        cin>>a[i]>>b[i]>>c[i];
    }
    init(n,m,a,b,c);
    int q;
    cin>>q;
    while(q--){
        int u,v;
        cin>>u>>v;
        cout<<getMinimumFuelCapacity(u,v)<<"\n";
    }
}*/
/*
 3
 1 10
 3 10
 8 15
 
2
1 2
2 3
*/
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 1 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 199 ms 10360 KB Output is correct
4 Correct 199 ms 14520 KB Output is correct
5 Correct 233 ms 14564 KB Output is correct
6 Correct 196 ms 14412 KB Output is correct
7 Correct 203 ms 14544 KB Output is correct
8 Correct 205 ms 14200 KB Output is correct
9 Correct 198 ms 14292 KB Output is correct
10 Correct 214 ms 14144 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 1 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 1 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 1 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 1 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -