Cod sursa(job #801423)

Utilizator valentin.harsanValentin Harsan valentin.harsan Data 24 octombrie 2012 11:37:00
Problema Triang Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.94 kb
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;

struct pct {
	int x, y;
};

const int N = 1510;
const double eps = 0.001;

int n, p[N], nr;

inline int m(int q) {return q > 0 ? q : -q;}

bool cmp(pct a, pct b) {
	if(m(a.x - b.x) < eps)
		return a.y < b.y;
	return a.x < b.x;
}

bool caut(int x, int y, int i) {
	int pas = 1<<12;
	
	for(; pas; pas>>=1)
		if(i + pas <= n && p[i + pas].x <= x + eps && p[i + pas].y <= y + eps)
			i += pas;
	
	return (m(p[i].x - x) <= eps && m(p[i].y - y) <= eps);
}

int main() {
	int i, j;
	
	freopen("triang.in", "r", stdin);
	freopen("triang.out", "w", stdout);
	
	cin >> n;
	
	for(i = 1; i<=n; ++i)
		cin >> p[i].x >> p[i].y;
	
	sort(p + 1, p + n + 1, cmp);
	
	for(i = 1; i!=n; ++i)
		for(j = i + 1; j<=n; ++j) {
			
			
			
			if(caut(nx, ny, j + 1))
				++nr;
			
			
			if(caut(nx, ny, j + 1))
				++nr;
		}
	cout << nr;
	
	return 0;
}