Submission #768483

#TimeUsernameProblemLanguageResultExecution timeMemory
768483green_gold_dogAdvertisement 2 (JOI23_ho_t2)C++17
100 / 100
1501 ms78860 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...