Submission #926623

#TimeUsernameProblemLanguageResultExecution timeMemory
926623De3b0oAdvertisement 2 (JOI23_ho_t2)C++14
59 / 100
5 ms3676 KiB
#include<bits/stdc++.h> #define ll long long #define F first #define S second #define in insert #define er erase #define pb push_back #define ppb pop_back() #define ph push #define pp pop() #define d3 ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); #define cans cout << ans << "\n"; #define yes cout << "YES" << "\n"; #define no cout << "NO" << "\n"; #define pll pair<ll,ll> #define lin cout << "\n"; #define sqr 340 #define mod 1000000007 using namespace std; pll a[1009]; vector<ll> adj[1009]; bool vis[1009]; void dfs(ll n) { if(vis[n]) return; vis[n]=1; for(auto it : adj[n]) dfs(it); } int main() { d3 ll n; cin >> n; for(int i = 0 ; n>i ; i++) cin >> a[i].S >> a[i].F; sort(a,a+n); for(int i = n-1 ; i>=0 ; i--) for(int j = i-1 ; j>=0 ; j--) if(a[i].F-a[j].F>=abs(a[i].S-a[j].S)) adj[i].pb(j); ll ans = 0; for(int i = n-1 ; i>=0 ; i--) { if(vis[i]) continue; ans++; dfs(i); } cans }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...