Submission #1149566

#TimeUsernameProblemLanguageResultExecution timeMemory
1149566Perl32Road Construction (JOI21_road_construction)C++17
Compilation error
0 ms0 KiB
//I wrote this code 4 u <3
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#ifdef LOCAL
#include "algo/debug.h"
#else
#define debug(...) 42
#endif

signed main(int32_t argc, char *argv[]) {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    ll n, k;
    cin >> n >> k;
    vector<pair<ll, ll>> a(n);
    for (auto& [x, y] : a) cin >> x >> y;
    vector<ll> srt;
    auto dst = [&](ll i, ll j) {
        return abs(a[i].first - a[j].first) + abs(a[i].second - a[j].second);
    };
    for (ll i = 0; i < n; ++i) {
        for (ll j = i + 1; j < n; ++j) {
            srt.push_back(dst(i, j));
        }
    }
    ranges::sort(srt);
    for (ll i = 0; i < k; ++i) cout << srt[i] << '\n';
}

/*

 */

Compilation message (stderr)

road_construction.cpp: In function 'int main(int32_t, char**)':
road_construction.cpp:30:5: error: 'ranges' has not been declared
   30 |     ranges::sort(srt);
      |     ^~~~~~