Submission #397820

#TimeUsernameProblemLanguageResultExecution timeMemory
397820yuto1115Swapping Cities (APIO20_swap)C++17
6 / 100
136 ms16048 KiB
#include "swap.h"
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rep2(i, s, n) for(ll i = ll(s); i < ll(n); i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vp = vector<P>;
using vvp = vector<vp>;
using vb = vector<bool>;
using vvb = vector<vb>;

template<class T>
bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

const int inf = 1001001001;

namespace {
    int n;
    vvp G;
    vi deg;
    int mx;
    bool cycle;
}

void init(int _n, int m, vi u, vi v, vi w) {
    n = _n;
    G.resize(n);
    deg.resize(n);
    mx = 0;
    rep(i, m) {
        G[u[i]].eb(v[i], w[i]);
        G[v[i]].eb(u[i], w[i]);
        deg[u[i]]++;
        deg[v[i]]++;
        chmax(mx, w[i]);
    }
    cycle = true;
    rep(i, n) cycle &= deg[i] == 2;
}

int getMinimumFuelCapacity(int x, int y) {
    return (cycle ? mx : -1);
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...