Cod sursa(job #197751)

Utilizator hadesgamesTache Alexandru hadesgames Data 5 iulie 2008 18:26:14
Problema Triplete Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 1.11 kb
#include <stdio.h>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <algorithm>
#include <utility>
#include <string>
#include <functional>
#include <sstream>
#include <fstream>
using namespace std;
#define FOR(i,a,b) for (typeof a i=a;i<=b;i++)
#define fori(it,v) for (typeof ((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define mp make_pair
#define fs first
#define ss second
#define all(c) c.begin(),c.end()
#define pf push_front
#define popb pop_back
#define popf pop_front
ofstream fout;
ostringstream out;
istringstream in;
void initializare_citire()
{
	ifstream fin;
	fin.open("triplete.in",ifstream::in);
	fout.open("triplete.out",ofstream::out);
	string aux;
	getline(fin,aux,'\0');
	in.str(aux);
	fin.close();
}
void scriere()
{
	fout<<out.str();
	fout.close();
}
vector<vector<bool> > a(4098,vector<bool>(4098,0));
int main()
{
	int n,m,nr=0,x,y;
	initializare_citire();
	in>>n>>m;
	FOR(i,1,m)
	{
		in>>x>>y;
		if(!a[x][y])
			FOR(j,1,n)
				if (a[x][j]&&a[y][j])
				{
					nr++;
					break;
				}
		a[x][y]=1;
		a[y][x]=1;
	}
	out<<nr;
	scriere();
	return 0;
}