Cod sursa(job #338666)

Utilizator Nickyu0712Nichita Utiu Nickyu0712 Data 6 august 2009 14:43:10
Problema Triplete Scor 30
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.71 kb
#include <fstream>

using namespace std;

long Result;
short n;
bool vPrieteni[4097][4097];

void Input();
void computeResult();
void Output();

int main() {
	Input();
	computeResult();
	Output();
	return 0;
}

void Input() {
	int m;
	ifstream fin("triplete.in");
	fin >> n >> m;
	for(short i=0,x,y; i<=m; i++ ) {
		fin >> x >> y;
		x<y?vPrieteni[x][y]=true:vPrieteni[y][x]=true;
	}
	fin.close();
}

void computeResult() {
	short i,j,l;
	for(i=1; i<=n; i++)
		for(j=i+1; j<n; j++)
			for(l=j+1; l<=n; l++)
				if(vPrieteni[i][j]==true && vPrieteni[i][l]==true && vPrieteni[j][l]==true)
					Result++;
}

void Output() {
	ofstream fout("triplete.out");
	fout << Result;
	fout.close();
}