#include <bits/stdc++.h>
using namespace std;
int main(){
int n;
cin>>n;
int ans=0;
pair<int,int> grid[n];
for (int i = 0; i < n; i++)
{
cin>>grid[i].first;
cin>>grid[i].second;
}
for (int i = 0; i < n; i++)
{
for (int j = i+1; j < n; j++)
{
if(grid[i].first==grid[j].first){
for (int d = 0; d < n; d++)
{
if(d!=i && d!= j && grid[i].first==grid[d].second){
ans++;
}
}
}
}
}
cout<<ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |