#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define int long long
#define pii pair<int,int>
#define ret return
#define fr first
#define sc second
#define OK puts("OK");
#define NO puts("NO");
#define YES puts("YES");
#define all(s) s.begin(),s.end()
#define allr(s) s.rbegin(),s.rend()
#define nosol puts("-1");
#define pb push_back
#define endi puts("");
const int N = 1e6+12,INF = 1e15+7;
#define ordered_set tree <int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
int y[N],x[N];
main(){
int n,i,x,y,ans=0;
cin>>n;
vector <pii> v;
map<int,int> mpx,mpy;
for (i=1;i<=n;++i){
cin>>x>>y;
mpx[x]++;
mpy[y]++;
v.pb({x,y});
}
for (auto p:v){
int x = p.fr,y = p.sc;
ans += (mpx[x]-1)*(mpy[y]-1);
}
cout <<ans;
}
Compilation message
triangle.cpp:24:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
24 | main(){
| ^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
304 KB |
Output is correct |
6 |
Correct |
0 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
304 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
292 KB |
Output is correct |
11 |
Correct |
1 ms |
332 KB |
Output is correct |
12 |
Correct |
10 ms |
1176 KB |
Output is correct |
13 |
Correct |
11 ms |
1184 KB |
Output is correct |
14 |
Correct |
20 ms |
1732 KB |
Output is correct |
15 |
Correct |
195 ms |
7908 KB |
Output is correct |
16 |
Correct |
190 ms |
8340 KB |
Output is correct |
17 |
Correct |
215 ms |
7904 KB |
Output is correct |
18 |
Correct |
167 ms |
7856 KB |
Output is correct |
19 |
Correct |
490 ms |
18420 KB |
Output is correct |
20 |
Correct |
329 ms |
11716 KB |
Output is correct |
21 |
Correct |
561 ms |
18464 KB |
Output is correct |
22 |
Correct |
534 ms |
18396 KB |
Output is correct |