이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
template<typename T>
bool assign_min(T& a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template<typename T>
bool assign_max(T& a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
struct cmp {
constexpr bool operator() (const pair<ll, ll>& p1, const pair<ll, ll>& p2) const {
return (p1.second == p2.second ? p1.first < p2.first : p1.second > p2.second);
}
};
struct sum_cmp {
constexpr bool operator() (const pair<ll, ll>& p1, const pair<ll, ll>& p2) const {
return (p1.first + p1.second == p2.first + p2.second ? p1.first < p2.first : p1.first + p1.second < p2.first + p2.second);
}
};
struct sub_cmp {
constexpr bool operator() (const pair<ll, ll>& p1, const pair<ll, ll>& p2) const {
return (p1.first - p1.second == p2.first - p2.second ? p1.first < p2.first : p1.first - p1.second > p2.first - p2.second);
}
};
void solve() {
ll n;
cin >> n;
set<pair<ll, ll>, cmp> s1;
set<pair<ll, ll>> all;
for (ll i = 0; i < n; i++) {
ll x, y;
cin >> x >> y;
s1.emplace(x, y);
all.emplace(x, y);
}
ll ans = 0;
while (!s1.empty()) {
ans++;
auto[x, y] = *s1.begin();
auto it = all.find(*s1.begin());
auto nit = it;
vector<pair<ll, ll>> del(1, *s1.begin());
while (nit != all.begin()) {
nit--;
auto[nx, ny] = *nit;
if (abs(nx - x) <= y - ny) {
del.push_back(*nit);
} else {
break;
}
}
nit = it;
nit++;
while (nit != all.end()) {
auto[nx, ny] = *nit;
if (abs(nx - x) <= y - ny) {
del.push_back(*nit);
} else {
break;
}
nit++;
}
for (auto i : del) {
all.erase(i);
s1.erase(i);
}
}
cout << ans << '\n';
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
solve();
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |