#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 = 1e18 + 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) - 1; 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 |
370 ms |
26308 KB |
Output is correct |
2 |
Correct |
362 ms |
26380 KB |
Output is correct |
3 |
Correct |
190 ms |
14648 KB |
Output is correct |
4 |
Correct |
145 ms |
14716 KB |
Output is correct |
5 |
Correct |
296 ms |
25312 KB |
Output is correct |
6 |
Correct |
157 ms |
23820 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
10040 ms |
372488 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
74 ms |
8208 KB |
Output is correct |
2 |
Correct |
72 ms |
8244 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
59 ms |
8400 KB |
Output is correct |
5 |
Correct |
88 ms |
9580 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
74 ms |
8208 KB |
Output is correct |
2 |
Correct |
72 ms |
8244 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
59 ms |
8400 KB |
Output is correct |
5 |
Correct |
88 ms |
9580 KB |
Output is correct |
6 |
Execution timed out |
10057 ms |
381188 KB |
Time limit exceeded |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
370 ms |
26308 KB |
Output is correct |
2 |
Correct |
362 ms |
26380 KB |
Output is correct |
3 |
Correct |
190 ms |
14648 KB |
Output is correct |
4 |
Correct |
145 ms |
14716 KB |
Output is correct |
5 |
Correct |
296 ms |
25312 KB |
Output is correct |
6 |
Correct |
157 ms |
23820 KB |
Output is correct |
7 |
Execution timed out |
10038 ms |
377132 KB |
Time limit exceeded |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
370 ms |
26308 KB |
Output is correct |
2 |
Correct |
362 ms |
26380 KB |
Output is correct |
3 |
Correct |
190 ms |
14648 KB |
Output is correct |
4 |
Correct |
145 ms |
14716 KB |
Output is correct |
5 |
Correct |
296 ms |
25312 KB |
Output is correct |
6 |
Correct |
157 ms |
23820 KB |
Output is correct |
7 |
Execution timed out |
10040 ms |
372488 KB |
Time limit exceeded |
8 |
Halted |
0 ms |
0 KB |
- |