268A. Games

Problem Link

<Source Code>

#include <bits/stdc++.h>
using namespace std;

#define INF 10000000

typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<vii> vvii;
typedef set<int> si;
typedef map<string, int> msi;

#define all(x) x.begin(), x.end()
#define tr(container, it) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define spresent(c,x) ((c).find(x) != (c).end())  // for set,map
#define present(c,x) (find(all(c),x) != (c).end())  // for vector
#define uu first
#define vv second
#define fr(i,a,b) for(int i=int(a);i<=int(b);++i)
#define nfr(i,a,b) for(int i= int(a);i>=int(b);--i)
vector<pair<int,int>>tmp(1000);
int main()
{
int n,i,q,co=0,j,p;
cin>>n;
for(i=0;i<n;i++)
    tmp.clear();
for(i=0;i<n;i++)
{
cin>>p>>q;
tmp.pb(mp(p,q));
}

for(i=0;i<n-1;i++)

{ for(j=i+1;j<n;j++){
if(tmp[i].uu==tmp[j].vv)
{

     co++;
}
if(tmp[i].vv==tmp[j].uu)
{
    co++;
}
}
}
cout<<co<<endl;
}
Advertisements

About waprogramming

I am in CSE,from CUET
This entry was posted in Uncategorized and tagged , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s