Submission #743478

# Submission time Handle Problem Language Result Execution time Memory
743478 2023-05-17T12:13:59 Z Mauve Swapping Cities (APIO20_swap) C++14
13 / 100
451 ms 20372 KB
#include "swap.h"
#include<bits/stdc++.h>
#define pb push_back
#define ss second
#define ff first
using namespace std;
int l,r,i,j,ii,jj,k,n,m,mx,subtask=1;
vector< pair<int,int> > v[100000];
set< pair<int,int> > st;
void init(int N, int M, vector<int> U, vector<int> V, vector<int> W) {
    n=N;
    m=M;
    for(i=0;i<M;i++){
        v[U[i]].pb({V[i],W[i]});
        v[V[i]].pb({U[i],W[i]});
        mx=max(mx,W[i]);
        st.insert({W[i],V[i]});
    }
    for(i=0;i<n;i++) if(v[i].size()>2) subtask=2;
}
int getMinimumFuelCapacity(int X, int Y) {
    if(subtask==1){
        if(n>m) return -1;
        else return mx;
    }

    if(n<=3) return -1;
    if(X==0 || Y==0){
        if(Y==0) swap(X,Y);
        st.erase({v[Y][0].ss,Y});
        mx=v[Y][0].ss;
        mx=max(mx,(*(++st.begin())).ff);
        st.insert({v[Y][0].ss,Y});
        return mx;
    }
    else{
    st.erase({v[X][0].ss,X});
    st.erase({v[Y][0].ss,Y});
    mx=max(v[X][0].ss,v[Y][0].ss);
    mx=max(mx,(*st.begin()).ff);
    st.insert({v[X][0].ss,X});
    st.insert({v[Y][0].ss,Y});
    return mx;
    }
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 2 ms 2652 KB Output is correct
3 Correct 2 ms 2548 KB Output is correct
4 Correct 2 ms 2660 KB Output is correct
5 Correct 2 ms 2660 KB Output is correct
6 Correct 3 ms 2664 KB Output is correct
7 Correct 2 ms 2664 KB Output is correct
8 Correct 2 ms 2676 KB Output is correct
9 Correct 69 ms 11432 KB Output is correct
10 Correct 104 ms 13644 KB Output is correct
11 Correct 90 ms 13480 KB Output is correct
12 Correct 101 ms 14140 KB Output is correct
13 Correct 96 ms 14152 KB Output is correct
14 Correct 72 ms 11816 KB Output is correct
15 Correct 157 ms 17848 KB Output is correct
16 Correct 138 ms 17520 KB Output is correct
17 Correct 153 ms 18248 KB Output is correct
18 Correct 166 ms 18200 KB Output is correct
19 Correct 54 ms 8820 KB Output is correct
20 Correct 138 ms 18784 KB Output is correct
21 Correct 148 ms 18796 KB Output is correct
22 Correct 152 ms 19568 KB Output is correct
23 Correct 148 ms 19636 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 2 ms 2652 KB Output is correct
3 Correct 404 ms 19076 KB Output is correct
4 Correct 405 ms 20224 KB Output is correct
5 Correct 427 ms 20292 KB Output is correct
6 Correct 429 ms 20096 KB Output is correct
7 Correct 418 ms 20372 KB Output is correct
8 Correct 370 ms 19824 KB Output is correct
9 Correct 451 ms 20148 KB Output is correct
10 Correct 387 ms 19764 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 2 ms 2652 KB Output is correct
3 Correct 2 ms 2548 KB Output is correct
4 Correct 2 ms 2660 KB Output is correct
5 Correct 2 ms 2660 KB Output is correct
6 Correct 3 ms 2664 KB Output is correct
7 Correct 2 ms 2664 KB Output is correct
8 Correct 2 ms 2676 KB Output is correct
9 Incorrect 2 ms 2644 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 2644 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 2 ms 2652 KB Output is correct
3 Correct 2 ms 2548 KB Output is correct
4 Correct 2 ms 2660 KB Output is correct
5 Correct 2 ms 2660 KB Output is correct
6 Correct 3 ms 2664 KB Output is correct
7 Correct 2 ms 2664 KB Output is correct
8 Correct 2 ms 2676 KB Output is correct
9 Correct 69 ms 11432 KB Output is correct
10 Correct 104 ms 13644 KB Output is correct
11 Correct 90 ms 13480 KB Output is correct
12 Correct 101 ms 14140 KB Output is correct
13 Correct 96 ms 14152 KB Output is correct
14 Correct 72 ms 11816 KB Output is correct
15 Correct 157 ms 17848 KB Output is correct
16 Correct 138 ms 17520 KB Output is correct
17 Correct 153 ms 18248 KB Output is correct
18 Correct 166 ms 18200 KB Output is correct
19 Correct 404 ms 19076 KB Output is correct
20 Correct 405 ms 20224 KB Output is correct
21 Correct 427 ms 20292 KB Output is correct
22 Correct 429 ms 20096 KB Output is correct
23 Correct 418 ms 20372 KB Output is correct
24 Correct 370 ms 19824 KB Output is correct
25 Correct 451 ms 20148 KB Output is correct
26 Correct 387 ms 19764 KB Output is correct
27 Incorrect 2 ms 2772 KB Output isn't correct
28 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 2644 KB Output isn't correct
2 Halted 0 ms 0 KB -