Submission #985250

# Submission time Handle Problem Language Result Execution time Memory
985250 2024-05-17T13:50:00 Z Aiperiii Swapping Cities (APIO20_swap) C++14
0 / 100
2000 ms 28360 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=1e3+5;
vector <pair <int,int> > g[N];
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++){
        g[V[i]].pb({U[i],W[i]});
        g[U[i]].pb({V[i],W[i]});
    }
}

int getMinimumFuelCapacity(int X, int Y) {
    vector <vector <int> > d(n,vector <int> (n,-1));
    d[X][Y]=0;
    set <pair <int,pair <int,int> > > st;
    st.insert({0,{X,Y}});
    while(!st.empty()){
        int a=st.begin()->ss.ff,b=st.begin()->ss.ss;
        st.erase(st.begin());
        for(auto to : g[a]){
            if(to.ff!=b){
                if(d[to.ff][b]==-1 or  d[to.ff][b]>max(d[a][b],to.ss)){
                    st.erase({d[to.ff][b],{to.ff,b}});
                    d[to.ff][b]=max(d[a][b],to.ss);
                    st.insert({d[to.ff][b],{to.ff,b}});
                }
            }
        }
        for(auto to : g[b]){
            if(to.ff!=a){
                if(d[a][to.ff]==-1 or d[a][to.ff]>max(d[a][b],to.ss)){
                    st.erase({d[a][to.ff],{a,to.ff}});
                    d[a][to.ff]=max(d[a][b],to.ss);
                    st.insert({d[a][to.ff],{a,to.ff}});
                }
            }
        }
    }
    return d[Y][X];
}

/*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
*/
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 71 ms 2488 KB Output is correct
5 Correct 281 ms 10700 KB Output is correct
6 Correct 312 ms 8368 KB Output is correct
7 Correct 392 ms 13224 KB Output is correct
8 Correct 380 ms 8036 KB Output is correct
9 Runtime error 20 ms 4184 KB Execution killed with signal 11
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Runtime error 49 ms 8020 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 71 ms 2488 KB Output is correct
5 Correct 281 ms 10700 KB Output is correct
6 Correct 312 ms 8368 KB Output is correct
7 Correct 392 ms 13224 KB Output is correct
8 Correct 380 ms 8036 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 763 ms 22056 KB Output is correct
11 Correct 808 ms 13860 KB Output is correct
12 Correct 844 ms 17812 KB Output is correct
13 Correct 616 ms 16324 KB Output is correct
14 Correct 773 ms 7480 KB Output is correct
15 Correct 808 ms 8336 KB Output is correct
16 Correct 804 ms 9324 KB Output is correct
17 Correct 788 ms 10568 KB Output is correct
18 Correct 1012 ms 25680 KB Output is correct
19 Correct 608 ms 14352 KB Output is correct
20 Correct 837 ms 14532 KB Output is correct
21 Correct 1543 ms 23116 KB Output is correct
22 Correct 239 ms 3388 KB Output is correct
23 Correct 723 ms 12364 KB Output is correct
24 Execution timed out 2055 ms 28360 KB Time limit exceeded
25 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 71 ms 2488 KB Output is correct
6 Correct 281 ms 10700 KB Output is correct
7 Correct 312 ms 8368 KB Output is correct
8 Correct 392 ms 13224 KB Output is correct
9 Correct 380 ms 8036 KB Output is correct
10 Runtime error 20 ms 4184 KB Execution killed with signal 11
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 71 ms 2488 KB Output is correct
5 Correct 281 ms 10700 KB Output is correct
6 Correct 312 ms 8368 KB Output is correct
7 Correct 392 ms 13224 KB Output is correct
8 Correct 380 ms 8036 KB Output is correct
9 Runtime error 20 ms 4184 KB Execution killed with signal 11
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 71 ms 2488 KB Output is correct
6 Correct 281 ms 10700 KB Output is correct
7 Correct 312 ms 8368 KB Output is correct
8 Correct 392 ms 13224 KB Output is correct
9 Correct 380 ms 8036 KB Output is correct
10 Runtime error 20 ms 4184 KB Execution killed with signal 11
11 Halted 0 ms 0 KB -