/*
Code written by Talant I.D.
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
typedef tuple <int, int, int> tiii;
#define precision(n) fixed << setprecision(n)
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define mp make_pair
#define mt make_tuple
#define mod (int)1e9+7
#define eps (double)1e-9
#define PI 2*acos(-0.0);
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define do_not_disturb ios::sync_with_stdio(0);cin.tie(0);
#define curMod 998244353
inline bool isvowel(char ch){
ch = tolower(ch);
return (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u');
}
bool isprime(int n){
if(n < 2 || (n % 2 == 0 && n != 2))
return false;
for(int i = 3; i*i <= n; i += 2)
if(n % i == 0) return false;
return true;
}
int main(){
do_not_disturb
int n, i;
map <int, vector<int>> orderX, orderY;
cin >> n;
vector <pii> points(n+1);
for(i = 1; i <= n; i++){
cin >> points[i].first >> points[i].second;
}
sort(all(points));
for(i = 1; i <= n; i++){
int x = points[i].first, y = points[i].second;
orderX[x].pb(y);
orderY[y].pb(x);
}
ll sum = 0;
for(i = 1; i <= n; i++){
int x = points[i].first, y = points[i].second;
auto it1 = lb(all(orderX[x]), y);
auto it2 = lb(all(orderY[y]), x);
ll d1 = orderX[x].size()-1, d2 = orderY[y].size()-1;
sum += d1*d2;
}
cout << sum;
return 0;
} // What is to be written here?
Compilation message
triangle.cpp: In function 'int main()':
triangle.cpp:61:8: warning: variable 'it1' set but not used [-Wunused-but-set-variable]
auto it1 = lb(all(orderX[x]), y);
^~~
triangle.cpp:62:8: warning: variable 'it2' set but not used [-Wunused-but-set-variable]
auto it2 = lb(all(orderY[y]), x);
^~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |