Cod sursa(job #219081)

Utilizator hadesgamesTache Alexandru hadesgames Data 5 noiembrie 2008 09:36:03
Problema Triplete Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 1 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
vector<vector<bool> > a(4098,vector<bool>(4098,0));
vector<bool> nre(4098,0);
fstream fin("triplete.in");
string s;
istringstream in;
int main()
{
	int n,m,nr=0,x,y;
	FILE *out;
	getline(fin,s,'\0');
	in.str(s);
	out=fopen("triplete.out","w");
	in>>n>>m;
	FOR(i,1,m)
	{
		in>>x>>y;
		if(!a[x][y]&&nre[x]&&nre[y])
			FOR(j,1,n)
				if (a[x][j]&&a[y][j])
				{
					nr++;
				}
		nre[x]=1;
		nre[y]=1;
		a[x][y]=1;
		a[y][x]=1;
	}
	fprintf(out,"%d\n",nr);
	fclose(out);
	return 0;
}