Cod sursa(job #2841892)

Utilizator andreipirjol5Andrei Pirjol andreipirjol5 Data 30 ianuarie 2022 17:03:24
Problema Trapez Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 1.17 kb
#include <cstdio>
#include <cstring>

using namespace std ;
FILE *fin, *fout ;

struct POINT {
    int x, int y ;
};

#define NMAX 1000
POINT v[NMAX + 5] ;
int fr[NMAX + 5] ;

int main() {
    fin = fopen("trapez.in", "r") ;
    fout = fopen("trapez.out", "w") ;

    int n ;
    fscanf(fin, "%d", &n) ;

    for(int i = 1 ; i <= n ; i++)
        fscanf(fin, "%d%d", &v[i].x, &v[i].y) ;
    for(int i = 1 ; i < n - 2 ; i++)
        for(int j = i + 1 ; j < n - 1 ; j++)
            for(int z = j + 1 ; z < n ; z++) {
                int cnt = 0 ;
                for(int k = z + 1 ; k <= n ; k++) {
                    fr[v[i].x]++;
                    fr[v[j].x]++;
                    fr[v[z].x]++;
                    fr[v[k].x]++;

                    if(fr[v[i].x] > 1)
                        cnt++;
                    if(fr[v[j].x] > 1)
                        cnt++;
                    if(fr[v[z].x] > 1)
                        cnt++;
                    if(fr[v[k].x] > 1)
                        cnt++;
                }
                memset(fr , 0 , sizeof(fr)) ;
            }
    fclose(fin) ;
    fclose(fout) ;
    return 0 ;
}