Submission #951518

# Submission time Handle Problem Language Result Execution time Memory
951518 2024-03-22T04:41:12 Z Nhoksocqt1 Swapping Cities (APIO20_swap) C++17
6 / 100
100 ms 17620 KB
#include<bits/stdc++.h>
using namespace std;

#define inf 0x3f3f3f3f
#define sz(x) int((x).size())
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> ii;

template<class X, class Y>
	inline bool maximize(X &x, const Y &y) {return (x < y ? x = y, 1 : 0);}
template<class X, class Y>
	inline bool minimize(X &x, const Y &y) {return (x > y ? x = y, 1 : 0);}

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int Random(int l, int r) {
    return uniform_int_distribution<int>(l, r)(rng);
}

const int MAXN = 100005;

struct Edge {
    int u, v, w;
} edge[2 * MAXN];

vector<ii> adj[MAXN];
int deg[MAXN], maxw, numNode, numEdge;
bool check_sub1, check_sub2;

void init(int _N, int _M, vector<int> _U, vector<int> _V, vector<int> _W) {
    numNode = _N, numEdge = _M;

    check_sub2 = 1;
    for (int i = 0; i < numEdge; ++i) {
        edge[i] = {_U[i], _V[i], _W[i]};
        adj[edge[i].u].push_back(ii(edge[i].v, edge[i].w));
        adj[edge[i].v].push_back(ii(edge[i].u, edge[i].w));
        check_sub2 &= (edge[i].u == 0);
        maxw = max(maxw, edge[i].w);
    }

    check_sub1 = 1;
    for (int i = 0; i < numNode; ++i)
        check_sub1 &= (sz(adj[i]) <= 2);

    sort(edge, edge + numEdge, [](const Edge &a, const Edge &b) {
        return (a.w < b.w);
    });
}

int getMinimumFuelCapacity(int x, int y) {
    if(check_sub1)
        return (numNode == numEdge) ? maxw : -1;

    return -1;
}

#ifdef Nhoksocqt1

int main(void) {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

    #define TASK "swap"
    if(fopen(TASK".inp", "r")) {
        freopen(TASK".inp", "r", stdin);
        freopen(TASK".out", "w", stdout);
    }

    vector<int> _U, _V, _W;
    int _N, _M, _Q;
    cin >> _N >> _M >> _Q;

    _U.resize(_M), _V.resize(_M), _W.resize(_M);
    for (int i = 0; i < _M; ++i) {
        cin >> _U[i] >> _V[i] >> _W[i];
    }

    init(_N, _M, _U, _V, _W);
    for (int t = 0; t < _Q; ++t) {
        int _X, _Y;
        cin >> _X >> _Y;
        cout << "MINIMUM FUEL CAPACITY " << _X << ' ' << " TO " << _Y << ": " << getMinimumFuelCapacity(_X, _Y) << '\n';
    }

    return 0;
}

#endif // Nhoksocqt1
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4540 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 2 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 31 ms 8820 KB Output is correct
10 Correct 38 ms 9820 KB Output is correct
11 Correct 39 ms 9528 KB Output is correct
12 Correct 41 ms 9812 KB Output is correct
13 Correct 53 ms 10064 KB Output is correct
14 Correct 35 ms 8796 KB Output is correct
15 Correct 83 ms 11468 KB Output is correct
16 Correct 81 ms 11724 KB Output is correct
17 Correct 82 ms 11708 KB Output is correct
18 Correct 87 ms 11744 KB Output is correct
19 Correct 41 ms 8788 KB Output is correct
20 Correct 84 ms 16928 KB Output is correct
21 Correct 82 ms 17332 KB Output is correct
22 Correct 100 ms 17620 KB Output is correct
23 Correct 82 ms 17592 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Incorrect 74 ms 12072 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4540 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 2 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Incorrect 2 ms 4444 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 4444 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4540 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 2 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 31 ms 8820 KB Output is correct
10 Correct 38 ms 9820 KB Output is correct
11 Correct 39 ms 9528 KB Output is correct
12 Correct 41 ms 9812 KB Output is correct
13 Correct 53 ms 10064 KB Output is correct
14 Correct 35 ms 8796 KB Output is correct
15 Correct 83 ms 11468 KB Output is correct
16 Correct 81 ms 11724 KB Output is correct
17 Correct 82 ms 11708 KB Output is correct
18 Correct 87 ms 11744 KB Output is correct
19 Incorrect 74 ms 12072 KB Output isn't correct
20 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 4444 KB Output isn't correct
2 Halted 0 ms 0 KB -