Submission #979590

# Submission time Handle Problem Language Result Execution time Memory
979590 2024-05-11T08:01:44 Z vjudge1 Swapping Cities (APIO20_swap) C++17
Compilation error
0 ms 0 KB
#include <time.h>
#include <cstdlib>
#include <stack>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <map>
#include <set>
#include <iterator>
#include <deque>
#include <queue>
#include <sstream>
#include <array>
#include <string>
#include <tuple>
#include <chrono>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <list>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <bitset>

using namespace std;

int tt = 1, n, m;
vector<pair<int, int>> g[200005];
pair<int, int> p[200005];
map<pair<int, int>, int> mp, pos;
set<pair<int, int>> st;

void init(){
    cin >> n >> m;
    for(int i = 1; i <= m; i++){
        int a, b, c;
        cin >> a >> b >> c;
        a++;
        b++;
        g[a].push_back({b, c});
        g[b].push_back({a, c});
        mp[{a, b}] = c;
        mp[{b, a}] = c;

        pos[{a, b}] = i;
        pos[{b, a}] = i;

        st.insert({c, i});
    }
}

int getMinimumFuelCapacity(int X, int Y){
    X++;
    Y++;
    if(n <= 3)
        return -1;
    int mx = 0;
    if(X != 1) mx = mp[{1, X}];
    if(Y != 1) mx = max(mx, mp[{1, Y}]);


    if(X != 1) st.erase({mp[{1, X}], pos[{1, X}]});
    if(Y != 1) st.erase({mp[{1, Y}], pos[{1, Y}]});
    
    pair<int, int> p = *st.begin();
    st.erase(st.begin());
    if(X != 1 && Y != 1){
        st.insert(p);
        if(X != 1) st.insert({mp[{1, X}], pos[{1, X}]});
        if(Y != 1) st.insert({mp[{1, Y}], pos[{1, Y}]});
        return max(mx, p.first);
    }
    else{
        pair<int, int> p1 = *st.begin();
        st.insert(p1);
        st.insert(p);
        if(X != 1) st.insert({mp[{1, X}], pos[{1, X}]});
        if(Y != 1) st.insert({mp[{1, Y}], pos[{1, Y}]});
        return max({mx, p.first, p1.first});
    }
}
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    init();
    cin >> tt;
    while(tt--){
        int x, y;
        cin >> x >> y;
        cout << getMinimumFuelCapacity(x, y) << "\n";
    }
}

Compilation message

/usr/bin/ld: /tmp/ccuxcQU5.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccui82n2.o:swap.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccuxcQU5.o: in function `main':
grader.cpp:(.text.startup+0x1c3): undefined reference to `init(int, int, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status