Submission #682232

# Submission time Handle Problem Language Result Execution time Memory
682232 2023-01-16T04:56:46 Z vjudge1 Road Construction (JOI21_road_construction) C++17
5 / 100
10000 ms 387568 KB
#include <bits/stdc++.h>

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")

using namespace std;

#define int long long
#define ll long long
#define vi vector<long long>
#define pb push_back
#define sz(s) (int)s.size()
#define all(v) v.begin(), v.end()
#define show(a) cerr << #a <<" -> "<< a <<"\n"
#define pp pair<int,int>
#define FF first
#define SS second
#define endl "\n"
#define ld long double

const int N = 1e6 + 2, N3 = 1e3 + 6, inf = 1e9 + 7, LOG = 20;
map<char, int> md{{'N', 0}, {'E', 1}, {'S', 2}, {'W', 3}};
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
string stepDir = "RDLU";

int n, k, x[N], y[N];
multiset <int> st;
vector <pp> v;

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

//	freopen(".in", "r", stdin);
//	freopen(".out", "w", stdout);

    cin >> n >> k;
    for (int i = 1; i <= n; i++) {
        cin >> x[i] >> y[i];
        v.pb({x[i], y[i]});
    }

    if (k == 1) {
        sort(all(v));
        int ans = inf;
        for (int i = 0; i < sz(v); i++) {
            ans = min(ans, abs(v[i].FF - v[i + 1].FF) + abs(v[i].SS - v[i + 1].SS));
        }
        cout << ans;
        return 0;
    }


    for (int i = 1; i <= n; i++) {
        for (int j = i + 1; j <= n; j++) {
            st.insert(abs(x[i] - x[j]) + abs(y[i] - y[j]));
        }
    }

    for (auto to : st) {
        cout << to << "\n";
        k--;
        if (k == 0) break;
    }

	return 0;
}

Compilation message

road_construction.cpp:3: warning: ignoring '#pragma comment ' [-Wunknown-pragmas]
    3 | #pragma comment(linker, "/stack:200000000")
      | 
road_construction.cpp:32:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   32 | main () {
      | ^~~~
# Verdict Execution time Memory Grader output
1 Correct 414 ms 26528 KB Output is correct
2 Correct 363 ms 26464 KB Output is correct
3 Correct 170 ms 14720 KB Output is correct
4 Correct 151 ms 14760 KB Output is correct
5 Correct 311 ms 25276 KB Output is correct
6 Correct 153 ms 23732 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 10091 ms 387568 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 72 ms 8284 KB Output is correct
2 Correct 76 ms 9552 KB Output is correct
3 Incorrect 1 ms 384 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 72 ms 8284 KB Output is correct
2 Correct 76 ms 9552 KB Output is correct
3 Incorrect 1 ms 384 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 414 ms 26528 KB Output is correct
2 Correct 363 ms 26464 KB Output is correct
3 Correct 170 ms 14720 KB Output is correct
4 Correct 151 ms 14760 KB Output is correct
5 Correct 311 ms 25276 KB Output is correct
6 Correct 153 ms 23732 KB Output is correct
7 Execution timed out 10035 ms 369468 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 414 ms 26528 KB Output is correct
2 Correct 363 ms 26464 KB Output is correct
3 Correct 170 ms 14720 KB Output is correct
4 Correct 151 ms 14760 KB Output is correct
5 Correct 311 ms 25276 KB Output is correct
6 Correct 153 ms 23732 KB Output is correct
7 Execution timed out 10091 ms 387568 KB Time limit exceeded
8 Halted 0 ms 0 KB -