Cod sursa(job #2960007)

Utilizator cosmadrianAdrian Cosma cosmadrian Data 3 ianuarie 2023 13:54:06
Problema Trapez Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.83 kb
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

struct point
{
	int x, y;
};

int main()
{
	int n;
	cin >> n;
	vector<point> points(n);
	for (int i = 0; i < n; i++)
	{
		cin >> points[i].x >> points[i].y;
	}
	sort(points.begin(), points.end(), [](point a, point b) {return a.x < b.x; });
	int ans = 0;
	for (int i = 0; i < n; i++)
	{
		int j = i + 1;
		while (j < n && points[j].x == points[i].x)
		{
			j++;
		}
		int k = j + 1;
		while (k < n && points[k].x == points[i].x)
		{
			k++;
		}
		for (int l = i + 1; l < j; l++)
		{
			for (int m = j + 1; m < k; m++)
			{
				for (int o = k + 1; o < n; o++)
				{
					if (points[l].y < points[i].y && points[m].y < points[i].y && points[o].y < points[i].y)
					{
						ans++;
					}
				}
			}
		}
		i = k - 1;
	}
	cout << ans << endl;
	return 0;
}