#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 ordered_set tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update>
#define nn "\n"
#define x_x ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define intt int _; cin >> _; while (_--)
#define emp push_back
#define mod 1000000007
#define all(v) v.begin(), v.end()
#define ld long double
#define A first
#define B second
typedef long long ll;
const ld eps = 1e-27;
// diff between decimals 0.000000001 mt19937 mt(time(nullptr));
int main() {
x_x
int n; cin>>n; vector<pair<int,int>>ar;
map<pair<int,int>,int>mp; map<int,ll>r,c;
for(int i=0,x,y; i<n; i++) {
cin>>x>>y; if (mp.find({x,y})==mp.end()) {mp[{x,y}]=1, r[x]++, c[y]++;
ar.emp({x,y});}
}
ll ans=0;
for(int i=0; i<ar.size(); i++) {
ans+=((r[ar[i].A]-1)*(c[ar[i].B]-1));
}
cout<<ans;
return 0;
}
Compilation message
triangle.cpp: In function 'int main()':
triangle.cpp:30:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
30 | for(int i=0; i<ar.size(); i++) {
| ~^~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
604 KB |
Output is correct |
12 |
Correct |
8 ms |
1884 KB |
Output is correct |
13 |
Correct |
8 ms |
1884 KB |
Output is correct |
14 |
Correct |
12 ms |
2548 KB |
Output is correct |
15 |
Correct |
130 ms |
13432 KB |
Output is correct |
16 |
Correct |
182 ms |
14280 KB |
Output is correct |
17 |
Correct |
145 ms |
13508 KB |
Output is correct |
18 |
Correct |
162 ms |
13544 KB |
Output is correct |
19 |
Correct |
492 ms |
31932 KB |
Output is correct |
20 |
Correct |
412 ms |
22716 KB |
Output is correct |
21 |
Correct |
509 ms |
33528 KB |
Output is correct |
22 |
Correct |
498 ms |
32492 KB |
Output is correct |