Cod sursa(job #1789600)

Utilizator borcanirobertBorcani Robert borcanirobert Data 27 octombrie 2016 10:49:56
Problema Puteri Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 1.09 kb
#include <fstream>
using namespace std;

ifstream fin("puteri.in");
ofstream fout("puteri.out");

const int MAXN = 100005;
const int MAXABC = 65;
int N, a[MAXN], b[MAXN], c[MAXN];
int n[MAXABC][MAXABC][MAXABC];
int rez;

void Read();
void Solve();

int main()
{
    Read();
    Solve();

    fout << rez;

    fin.close();
    fout.close();
    return 0;
}

void Read()
{
    int i;

    fin >> N;
    for ( i = 1; i <= N; i++ )
    {
        fin >> a[i] >> b[i] >> c[i];
        n[a[i]][b[i]][c[i]]++;
    }
}

void Solve()
{
    int i, j, p1, p2, p3, x;

    for ( i = 1; i <= N; i++ )
    {
        n[a[i]][b[i]][c[i]]--;

        x = max( a[i], max( b[i], c[i] ) );

        for ( x = x % 2 ? x + 1 : x; x <= 64; x += 2 )
        {
            /// p1 > 0, p2 > 0, p3 > 0
            p1 = x - a[i];
            p2 = x - b[i];
            p3 = x - c[i];

            rez += n[p1][p2][p3];

            /// p3 == 0
            if ( c[i] == 0 )
            {
                p3 = 0;
                rez += n[p1][p2][p3];
            }
        }
    }
}