#include <bits/stdc++.h>
using namespace std;
#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(0)
#define FOR(i, a, b) for(int i = (a); i <= (b); i++)
#define REP(n) FOR(O, 1, (n))
#define pb push_back
#define f first
#define s second
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int MAXN = 250100, MAXK = 20;
const ll MOD = 1e9+7;
int n, k;
ll x[MAXN], y[MAXN];
ll dst (int i, int j) {
return abs(x[i] - x[j]) + abs(y[i] - y[j]);
}
vector<ll> d;
void solve1 () {
FOR(i, 1, n) FOR(j, i+1, n)
d.pb(dst(i, j));
sort(d.begin(), d.end());
FOR(i, 0, k-1)
cout << d[i] << "\n";
exit(1);
}
//int toLe[MAXN], toRi[MAXN];
priority_queue<pair<ll, pii>, vector<pair<ll, pii>>, greater<pair<ll, pii>>> q;
void solve2 () {
sort(x+1, x+n+1);
// FOR(i, 1, n) toLe[i] = toRi[i] = i;
FOR(i, 1, n-1) {
ll d = dst(i, i+1);
q.push({d, {i,i+1}});
}
while (!q.empty()) {
auto p = q.top();
q.pop();
ll d = p.f;
int i = p.s.f, j = p.s.s;
cout << d << "\n";
if (j < n) {
q.push({dst(i, j+1), {i,j+1}});
}
}
//cout << " ksdfsdf" << endl;
}
int main()
{
FAST_IO;
cin >> n >> k;
FOR(i, 1, n) cin >> x[i] >> y[i];
bool sub2 = true;
FOR(i, 1, n) if (y[i] != 0) sub2 = false;
if (sub2) solve2();
else solve1();
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
65 ms |
6964 KB |
Execution failed because the return code was nonzero |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
10007 ms |
208528 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1856 ms |
2097156 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1856 ms |
2097156 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
65 ms |
6964 KB |
Execution failed because the return code was nonzero |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
65 ms |
6964 KB |
Execution failed because the return code was nonzero |
2 |
Halted |
0 ms |
0 KB |
- |