QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#496972 | #6136. Airdrop | ucup-team1198# | AC ✓ | 561ms | 13392kb | C++20 | 2.0kb | 2024-07-28 17:28:08 | 2024-07-28 17:28:09 |
Judging History
answer
#include <map>
#include <set>
#include <array>
#include <cmath>
#include <deque>
#include <bitset>
#include <random>
#include <string>
#include <vector>
#include <cassert>
#include <complex>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
using namespace std;
void solve() {
int n, y0;
cin >> n >> y0;
vector<pair<int, int>> points(n);
for (int i = 0; i < n; ++i)
cin >> points[i].first >> points[i].second;
sort(points.begin(), points.end());
vector<int> allx(n);
for (int i = 0; i < n; ++i)
allx[i] = points[i].first;
for (int i = 0; i + 1 < n; ++i) {
if (allx[i] + 1 < allx[i + 1])
allx.emplace_back(allx[i] + 1);
}
allx.emplace_back(allx[0] - 1);
allx.emplace_back(allx[n - 1] + 1);
sort(allx.begin(), allx.end());
allx.resize(unique(allx.begin(), allx.end()) - allx.begin());
map<int, int> answers;
for (int _ = 0; _ < 2; ++_) {
auto get_type = [&](pair<int, int> point) {
if (_ == 0)
return point.first - abs(point.second - y0);
return point.first + abs(point.second - y0);
};
set<int> walking;
int i = 0;
for (int x : allx) {
answers[x] += walking.size();
map<int, int> new_types;
int cur = 0;
for (; i < n && points[i].first == x; ++i) {
int t = get_type(points[i]);
++cur;
++new_types[t];
}
for (auto [t, c] : new_types) {
if (walking.count(t)) {
walking.erase(t);
} else if (c == 1) {
walking.emplace(t);
}
}
if (_ == 0)
answers[x] += cur;
}
reverse(allx.begin(), allx.end());
reverse(points.begin(), points.end());
}
int mn = 1e9, mx = -1e9;
for (auto [x, ans] : answers) {
mn = min(mn, ans);
mx = max(mx, ans);
}
cout << mn << ' ' << mx << '\n';
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t;
cin >> t;
while (t--) {
solve();
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3820kb
input:
3 3 2 1 2 2 1 3 5 3 3 2 1 2 5 4 3 2 3 1 3 4 3
output:
1 3 0 3 2 2
result:
ok 6 numbers
Test #2:
score: 0
Accepted
time: 561ms
memory: 13392kb
input:
3508 6 1 7 1 1 1 9 1 10 1 3 1 4 1 3 8 8 9 8 7 1 8 9 5 10 1 10 8 10 2 5 1 9 9 5 9 10 9 6 4 4 7 6 7 10 5 3 8 9 5 9 9 7 5 4 7 10 5 6 9 9 5 6 6 9 3 3 2 5 1 3 8 6 4 5 9 10 2 2 9 10 10 10 8 4 1 7 1 6 1 3 1 5 1 2 4 9 3 3 3 4 5 3 8 9 6 9 9 6 3 9 5 9 3 2 9 9 1 9 2 4 1 5 4 5 6 6 5 9 8 4 1 2 1 5 1 7 1 3 1 9 10...
output:
6 6 1 3 1 5 2 6 2 6 0 2 4 4 2 2 4 4 4 7 4 4 9 9 4 6 0 3 2 6 2 2 2 6 10 10 9 9 1 3 2 4 0 2 2 4 4 7 6 6 9 9 2 2 2 2 3 5 1 4 2 2 1 1 3 5 4 7 3 6 1 1 5 7 5 5 1 3 2 2 1 7 1 1 4 6 2 4 2 6 2 4 1 7 2 4 9 9 0 3 1 1 3 8 2 2 2 2 9 9 3 7 4 4 4 6 2 5 0 2 2 5 3 3 0 4 4 4 2 4 2 2 4 6 6 6 6 6 0 2 2 6 2 4 2 6 2 5 1 ...
result:
ok 7016 numbers