Submission #305062

# Submission time Handle Problem Language Result Execution time Memory
305062 2020-09-22T13:50:45 Z aryan12 Swapping Cities (APIO20_swap) C++17
0 / 100
2000 ms 13876 KB
#include "swap.h"
#include <bits/stdc++.h>
using namespace std;

const int N = 1e5 + 10;
vector<pair<int, int> > g[N];
int GlobalN, GlobalM;

int getMinimumFuelCapacity(int x, int y) {
    if(x == 0 || y == 0 || GlobalN <= 3)
        return -1;
    int one = max(g[x][0].first, g[y][0].first), two = INT_MAX;
    /*cout << g[0].size() << " " << GlobalN << " " << GlobalM << endl;
    for(int i = 0; i < GlobalN; i++) {
        for(int j = 0; j < g[i].size(); j++) {
            cout << g[i][j].first << " " << g[i][j].second << endl;
        }
        cout << endl;
    }*/
    for(int i = 1; i < GlobalN; i++) {
        if(i == x || i == y)
            continue;
        two = min(two, g[i][0].first);
    }
    if(two == INT_MAX)
        return -1;
    return max(one, two);
}

/*void SolveSubtasks(int n, int m, vector<int> u, vector<int> v, vector<int> w) {
    int q;
    cin >> q;
    for(int i = 1; i <= q; i++) {
        int x, y;
        cin >> x >> y;
        cout << getMinimumFuelCapacity(x, y) << endl;
    }
}*/

void init(int n, int m, vector<int> u, vector<int> v, vector<int> w) {
    GlobalM = m;
    GlobalN = n;
    for(int i = 0; i < u.size(); i++) {
        g[u[i]].push_back({w[i], v[i]});
        g[v[i]].push_back({w[i], u[i]});
        //cout << u[i] << " " << v[i] << " " << g[u[i]].size() << " " << g[v[i]].size() << endl;
    }
    //SolveSubtasks(n, m, u, v, w);
}

/*int main() {
    int n, m;
    vector<int> u, v, w;
    cin >> n >> m;
    for(int i = 0; i < m; i++) {
        int x, y, z;
        cin >> x >> y >> z;
        u.push_back(x);
        v.push_back(y);
        w.push_back(z);
    }
    init(n, m, u, v, w);
}
*/

Compilation message

swap.cpp: In function 'void init(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
swap.cpp:43:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |     for(int i = 0; i < u.size(); i++) {
      |                    ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2688 KB Output is correct
2 Correct 2 ms 2688 KB Output is correct
3 Correct 2 ms 2720 KB Output is correct
4 Incorrect 3 ms 2688 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2688 KB Output is correct
2 Correct 2 ms 2688 KB Output is correct
3 Execution timed out 2080 ms 13876 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 2688 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 2688 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2688 KB Output is correct
2 Correct 2 ms 2688 KB Output is correct
3 Correct 2 ms 2720 KB Output is correct
4 Incorrect 3 ms 2688 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 2688 KB Output isn't correct