#include <bits/stdc++.h>
#define kyou using
#define mo namespace
#define kawaii std
kyou mo kawaii;
#define ll long long
#define ld long double
#define endl "\n"
const int MX = 2005;
const int LG = (int)log2(MX) + 1;
const int BLOCK = 205;
const int inf = 1000000069;
const ll inf_ll = 8000000000000000069ll;
const ld inf_ld = (ld)inf_ll;
const ld eps = 1e-9;
const ll mod = 1000000007;
const int alpha = 30;
const int dxh[] = {1, 1, -1, -1, 2, 2, -2, -2};
const int dyh[] = {2, -2, 2, -2, 1, -1, 1, -1}; // horse
const int dx[] = {1, -1, 0, 0, 0, 0};
const int dy[] = {0, 0, 1, -1, 0, 0}; // adj
const int dz[] = {0, 0, 0, 0, 1, -1}; // 3d
const int dxd[] = {1, 1, 1, 0, -1, -1, -1, 0};
const int dyd[] = {1, 0, -1, -1, -1, 0, 1, 1}; // diag
mt19937 rng(time(NULL));
bool untied = 0;
void setIn(string s){freopen(s.c_str(), "r", stdin);}
void setOut(string s){freopen(s.c_str(), "w", stdout);}
void unsyncIO(){cin.tie(0) -> sync_with_stdio(0);}
void setIO(string s = ""){
if(!untied) unsyncIO(), untied = 1;
if(s.size()){
setIn(s + ".in");
setOut(s + ".out");
}
}
map<int, int> cntX, cntY;
int main(){
setIO();
int n; cin >> n;
vector<pair<int, int> > pt(n);
for(int i = 0; i < n; i ++){
cin >> pt[i].first >> pt[i].second;
cntX[pt[i].first] ++;
cntY[pt[i].second] ++;
}
ll ans = 0ll;
for(int i = 0; i < n; i ++)
ans += (cntX[pt[i].first] - 1) * 1ll * (cntY[pt[i].second] - 1);
cout << ans << endl;
return 0;
}
Compilation message
triangle.cpp: In function 'void setIn(std::string)':
triangle.cpp:31:29: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
31 | void setIn(string s){freopen(s.c_str(), "r", stdin);}
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
triangle.cpp: In function 'void setOut(std::string)':
triangle.cpp:32:30: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
32 | void setOut(string s){freopen(s.c_str(), "w", stdout);}
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
280 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
316 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
332 KB |
Output is correct |
12 |
Correct |
7 ms |
972 KB |
Output is correct |
13 |
Correct |
7 ms |
972 KB |
Output is correct |
14 |
Correct |
12 ms |
1356 KB |
Output is correct |
15 |
Correct |
115 ms |
6096 KB |
Output is correct |
16 |
Correct |
125 ms |
6428 KB |
Output is correct |
17 |
Correct |
117 ms |
6084 KB |
Output is correct |
18 |
Correct |
116 ms |
6068 KB |
Output is correct |
19 |
Correct |
329 ms |
11544 KB |
Output is correct |
20 |
Correct |
250 ms |
9156 KB |
Output is correct |
21 |
Correct |
348 ms |
12136 KB |
Output is correct |
22 |
Correct |
358 ms |
12132 KB |
Output is correct |