#include <bits/stdc++.h>
#define fr first
#define sc second
#define pb push_back
#define mk make_pair
#define int long long
#define OK puts("OK")
#define sz(s) (int)s.size()
#define all(s) s.begin(), s.end()
using namespace std;
const int N = 3e5+10;
const int inf = 1e9+7;
int n , l ,r;
pair < int,int > a[N];
int ans = 0;
map < int , int > x , y ;
main(){
cin >> n;
for(int i = 1 ; i <= n ; i++ )
{
cin >> a[i].fr >> a[i].sc;
x[a[i].fr] ++ ;
y[a[i].sc] ++ ;
}
for(int i = 1 ; i <= n ; i++ )
{
l = x[a[i].fr] -1 ;
r = y[a[i].sc] -1 ;
ans += l*r ;
}
cout << ans << endl;
}
Compilation message
triangle.cpp:21:7: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
main(){
^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
380 KB |
Output is correct |
3 |
Correct |
2 ms |
380 KB |
Output is correct |
4 |
Correct |
2 ms |
440 KB |
Output is correct |
5 |
Correct |
2 ms |
488 KB |
Output is correct |
6 |
Correct |
2 ms |
488 KB |
Output is correct |
7 |
Correct |
2 ms |
488 KB |
Output is correct |
8 |
Correct |
2 ms |
504 KB |
Output is correct |
9 |
Correct |
2 ms |
516 KB |
Output is correct |
10 |
Correct |
3 ms |
532 KB |
Output is correct |
11 |
Correct |
3 ms |
536 KB |
Output is correct |
12 |
Correct |
16 ms |
1300 KB |
Output is correct |
13 |
Correct |
18 ms |
1428 KB |
Output is correct |
14 |
Correct |
23 ms |
1700 KB |
Output is correct |
15 |
Correct |
253 ms |
5924 KB |
Output is correct |
16 |
Correct |
314 ms |
6156 KB |
Output is correct |
17 |
Correct |
247 ms |
6156 KB |
Output is correct |
18 |
Correct |
272 ms |
6156 KB |
Output is correct |
19 |
Correct |
760 ms |
9016 KB |
Output is correct |
20 |
Correct |
497 ms |
9016 KB |
Output is correct |
21 |
Correct |
761 ms |
9468 KB |
Output is correct |
22 |
Correct |
815 ms |
9468 KB |
Output is correct |