Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // dile a la jardinera que traigo flores
- // corner cases // int vs ll // cin vs scanf
- #include <bits/stdc++.h>
- #define ff first
- #define ss second
- #define mp make_pair
- #define pb push_back
- #define sz(x) int(x.size())
- #define fill(x,v) memset(x,v,sizeof(x))
- #define FER(i,a,b) for(int i = int(a); i < int(b); ++i)
- #define trace(x) cout << #x << " = " << x << endl
- #define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
- using namespace std;
- typedef long long ll;
- typedef pair<int,int> ii;
- vector< vector<int> > dots;
- map<int,vector<int> > mapa;
- int check(int id, int x1, int x2){
- auto it = lower_bound(dots[id].begin(),dots[id].end(),x1);
- if(it == dots[id].end()) return 0;
- int val = *it;
- it++;
- if(val == x1 and it != dots[id].end() and *it == x2) return 1;
- if(val > x2) return 0;
- return -1;
- }
- int main(){
- fastio;
- int n,x,y;
- cin >> n;
- FER(i,0,n){
- cin >> x >> y;
- mapa[y].pb(x);
- }
- int c = 0;
- dots.resize(sz(mapa));
- for(auto &par : mapa){
- dots[c] = par.second;
- sort(dots[c].begin(),dots[c].end());
- c++;
- }
- int ans = 0;
- for(int i = 0; i < sz(dots); ++i){
- for(int j = 0; j < sz(dots[i])-1; ++j){
- int x1 = dots[i][j], x2 = dots[i][j+1];
- for(int k = i-1; k >= 0; --k){
- int res = check(k,x1,x2);
- if(res == 1) ans++;
- if(res == 1 or res == -1) break;
- }
- for(int k = i+1; k < sz(dots); ++k){
- int res = check(k,x1,x2);
- if(res == 1) ans++;
- if(res == 1 or res == -1) break;
- }
- }
- }
- cout << ans/2 << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement