Cod sursa(job #3354665)

Utilizator Nicky_DumitracheNicolae Dumitrache Nicky_Dumitrache Data 19 mai 2026 17:50:34
Problema Infasuratoare convexa Scor 0
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.78 kb
#include <fstream>
#include <iostream>
#include <algorithm>

struct pct
{
	int p;
    double x, y;
};

bool abc(pct x, pct y)
{
    if(x.x < y.x) return 1;
    else if(x.x == y.x && x.y < y.y) return 1;
    return 0;
}

int main()
{
    int n, i, s1[120001], s2[120001], k1 = 0, k2 = 0;
    pct z[120001];
    std::ifstream fi("infasuratoare.in");
    std::ofstream fo("infasuratoare.out");
    fi >> n;
    for(i = 0; i < n; i++) fi >> z[i].x >> z[i].y;
    std::sort(z, z + n, abc);
    pct a = z[0], b = z[n - 1];
	for(i = 0 ; i < n; i++)
	{
		pct c = z[i];
		int arie = a.x*b.y + b.x*c.y + c.x*a.y -b.y*c.x -c.y*a.x - a.y*b.x;
		if(arie > 0) z[i].p = 0;
		else if(arie < 0) z[i].p = 1;
		else z.p = 2;
	}
	for(i = 0; i < n; i++)
	{
		if(z.p == 1);
	}
}