Submission #398278

#TimeUsernameProblemLanguageResultExecution timeMemory
398278yuto1115Fun Tour (APIO20_fun)C++17
26 / 100
24 ms1356 KiB
#include "fun.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;

vi createFunTour(int n, int q) {
    assert(n <= 500);
    vvi dist(n, vi(n));
    int pos, mx = 0;
    rep(i, n) rep(j, n) {
            dist[i][j] = hoursRequired(i, j);
            if (chmax(mx, dist[i][j])) pos = i;
        }
    int now = pos;
    vi ans = {now};
    vb seen(n);
    seen[now] = true;
    rep(_, n - 1) {
        mx = 0;
        rep(i, n) {
            if (seen[i]) continue;
            if (chmax(mx, dist[now][i])) pos = i;
        }
        now = pos;
        ans.pb(now);
        seen[now] = true;
    }
    return ans;
}

Compilation message (stderr)

fun.cpp: In function 'vi createFunTour(int, int)':
fun.cpp:52:13: warning: 'pos' may be used uninitialized in this function [-Wmaybe-uninitialized]
   52 |     seen[now] = true;
      |             ^
#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...