Cod sursa(job #3257156)

Utilizator Cyb3rBoltSbora Ioan-David Cyb3rBolt Data 16 noiembrie 2024 19:44:47
Problema Pachete Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.84 kb
#include <bits/stdc++.h>

using namespace std;
ifstream fin("pachete.in");
ofstream fout("pachete.out");
int n, cnt = 0, sol[50010];

struct pereche {
    ///cine stie cunoaste
    int x, y;
    void read() { fin >> x >> y; }
}v[50010];
pereche start;

inline int ecDreptei(int x, int y, int x1, int y1, int x2, int y2) {
    ///verifica daca (x, y) e pe dreapta care trece prin (x1, y1) si (x2, y2) cf ec dr
    return (((x - x1) * (y2 - y1)) == ((x2 - x1) * (y - y1)));
}

int main()
{
    fin >> n;
    start.read();
    for(int i=1; i<=n; i++) v[i].read();
    for(int i=1; i<=n; i++) {
        bool ok = false;
        for(int j=1; j<=cnt && !ok; j++)
            if(ecDreptei(v[i].x, v[i].y, start.x, start.y, v[sol[j]].x, v[sol[j]].y)) ok = true;
        if(!ok) sol[++cnt] = i;
    }
    fout << cnt;

    return 0;
}