0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-12-24 03:11:58 +00:00

#3491. 「JOISC 2021 Day2」道路建设

https://loj.ac/s/1688581
This commit is contained in:
Baoshuo Ren 2023-01-31 14:39:25 +08:00
parent 789d98729b
commit 28b5e46c97
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A
85 changed files with 348 additions and 0 deletions

96
LibreOJ/3491/3491.cpp Normal file
View File

@ -0,0 +1,96 @@
#include <iostream>
#include <algorithm>
#include <queue>
#include <set>
#include <utility>
#include <vector>
using std::cin;
using std::cout;
const char endl = '\n';
const long long INF = 0x3f3f3f3f'3f3f3f3f;
int n, k;
std::vector<std::pair<long long, long long>> points;
bool check(long long x) {
int cnt = 0;
std::queue<std::pair<long long, long long>> q;
std::set<std::pair<long long, long long>> set;
for (auto o : points) {
while (!q.empty() && q.front().first + x < o.first) {
set.erase({q.front().second, q.front().first});
q.pop();
}
cnt += std::distance(set.lower_bound({o.second - x, -INF}), set.upper_bound({o.second + x, INF}));
if (cnt >= k) return true;
set.emplace(o.second, o.first);
q.emplace(o);
}
return false;
}
int main() {
std::ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n >> k;
for (int i = 1, x, y; i <= n; i++) {
cin >> x >> y;
points.emplace_back(x + y, x - y);
}
std::sort(points.begin(), points.end());
long long l = 0,
r = INF,
res;
while (l <= r) {
long long mid = (l + r) >> 1;
if (check(mid)) {
res = mid;
r = mid - 1;
} else {
l = mid + 1;
}
}
std::vector<long long> ans;
std::queue<std::pair<long long, long long>> q;
std::set<std::pair<long long, long long>> set;
for (auto o : points) {
while (!q.empty() && q.front().first + res - 1 < o.first) {
set.erase({q.front().second, q.front().first});
q.pop();
}
std::transform(
set.lower_bound({o.second - res + 1, -INF}),
set.upper_bound({o.second + res - 1, INF}),
std::back_inserter(ans),
[&](const std::pair<long long, long long>& item) -> long long {
return std::max(std::abs(item.first - o.second), o.first - item.second);
});
set.emplace(o.second, o.first);
q.emplace(o);
}
std::sort(ans.begin(), ans.end());
ans.resize(k, res);
for (auto x : ans) cout << x << endl;
return 0;
}

BIN
LibreOJ/3491/data/01-01.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/3491/data/01-01.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/3491/data/01-02.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/3491/data/01-02.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/3491/data/01-03.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/3491/data/01-03.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/3491/data/01-04.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/3491/data/01-04.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/3491/data/01-05.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/3491/data/01-05.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/3491/data/01-06.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/3491/data/01-06.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/3491/data/02-01.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/3491/data/02-01.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/3491/data/02-02.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/3491/data/02-02.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/3491/data/02-03.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/3491/data/02-03.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/3491/data/02-04.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/3491/data/02-04.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/3491/data/02-05.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/3491/data/02-05.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/3491/data/02-06.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/3491/data/02-06.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/3491/data/02-07.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/3491/data/02-07.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/3491/data/03-01.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/3491/data/03-01.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/3491/data/03-02.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/3491/data/03-02.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/3491/data/03-03.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/3491/data/03-03.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/3491/data/03-04.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/3491/data/03-04.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/3491/data/03-05.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/3491/data/03-05.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/3491/data/04-01.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/3491/data/04-01.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/3491/data/04-02.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/3491/data/04-02.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/3491/data/04-03.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/3491/data/04-03.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/3491/data/04-04.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/3491/data/04-04.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/3491/data/04-05.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/3491/data/04-05.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/3491/data/04-06.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/3491/data/04-06.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/3491/data/04-07.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/3491/data/04-07.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/3491/data/05-01.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/3491/data/05-01.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/3491/data/05-02.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/3491/data/05-02.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/3491/data/05-03.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/3491/data/05-03.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/3491/data/05-04.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/3491/data/05-04.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/3491/data/05-05.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/3491/data/05-05.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/3491/data/05-06.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/3491/data/05-06.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/3491/data/05-07.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/3491/data/05-07.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/3491/data/06-01.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/3491/data/06-01.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/3491/data/06-02.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/3491/data/06-02.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/3491/data/06-03.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/3491/data/06-03.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/3491/data/06-04.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/3491/data/06-04.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/3491/data/06-05.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/3491/data/06-05.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/3491/data/06-06.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/3491/data/06-06.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/3491/data/sample-01.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/3491/data/sample-01.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/3491/data/sample-02.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/3491/data/sample-02.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/3491/data/sample-03.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/3491/data/sample-03.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/3491/data/sample-04.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/3491/data/sample-04.out (Stored with Git LFS) Normal file

Binary file not shown.