#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define X first
#define Y second
#define mpr make_pair
ll n,x[300005],y[30005],cnt=0,num,xx,yy;
map<ll,ll> mp1,mp2;
map<pair<ll,ll>,ll> mp;
map<pair<ll,ll>,ll> :: iterator it;
int main()
{
scanf("%lld",&n);
for(int i=1;i<=n;i++)
{
scanf("%lld%lld",&x[i],&y[i]);
++mp1[x[i]],++mp2[y[i]];
++mp[mpr(x[i],y[i])];
}
for(it=mp.begin();it!=mp.end();it++)
{
num=(*it).Y;
xx=(*it).X.X;
yy=(*it).X.Y;
cnt+=(mp1[xx]-num)*(mp2[yy]-num)*num;
}
printf("%lld\n",cnt);
}
Compilation message
triangle.cpp: In function 'int main()':
triangle.cpp:13:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
13 | scanf("%lld",&n);
| ~~~~~^~~~~~~~~~~
triangle.cpp:16:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
16 | scanf("%lld%lld",&x[i],&y[i]);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
0 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
8 ms |
1620 KB |
Output is correct |
13 |
Correct |
7 ms |
1620 KB |
Output is correct |
14 |
Correct |
12 ms |
2060 KB |
Output is correct |
15 |
Correct |
156 ms |
11396 KB |
Output is correct |
16 |
Correct |
172 ms |
14448 KB |
Output is correct |
17 |
Correct |
189 ms |
13584 KB |
Output is correct |
18 |
Correct |
151 ms |
13588 KB |
Output is correct |
19 |
Correct |
563 ms |
30284 KB |
Output is correct |
20 |
Correct |
370 ms |
23016 KB |
Output is correct |
21 |
Correct |
549 ms |
32204 KB |
Output is correct |
22 |
Correct |
586 ms |
32200 KB |
Output is correct |