#include<iostream>
int main()
{
    using namespace std;
    int j,i,t=0,n,a[50],b[50];
    cin>>n;
    for(i=1;i<=n;i++)cin>>a[i]>>b[i];
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=n;j++)
        {
            if(a[i]==b[j]&&i!=j)t++;
        }
    }
    cout<<t;
    return 0;
}

http://codeforces.com/contest/268/problem/A

posted on 2013-02-08 20:50  海暗  阅读(173)  评论(0编辑  收藏  举报