# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
499047 | ac2hu | 별들과 삼각형 (IZhO11_triangle) | C++14 | 118 ms | 3188 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 10;
int comp1[maxn];
int comp2[maxn];
signed main(){
iostream::sync_with_stdio(false);
cin.tie(nullptr);cout.tie(nullptr);
int n;cin >> n;
vector<pair<int,int>> stars(n);
for(int i = 0;i<n;i++){
cin >> stars[i].first >> stars[i].second;
}
sort(stars.begin(),stars.end());
int c = 0;
int k = stars[0].first;
stars[0].first = 0;
for(int i = 1;i<n;i++){
if(stars[i].first != k){
c++;
k = stars[i].first;
}
stars[i].first = c;
}
sort(stars.begin(),stars.end(),[&](pair<int,int> a,pair<int,int> b){
return a.second < b.second;
});
c = 0;
k = stars[0].second;
stars[0].second = 0;
for(int i = 1;i<n;i++){
if(stars[i].second != k){
c++;
k = stars[i].second;
}
stars[i].second = c;
}
for(int i = 0;i<n;i++){
comp1[stars[i].first]++;
comp2[stars[i].second]++;
}
long long int ans = 0;
for(int i = 0;i<n;i++){
ans += 1ll*(comp1[stars[i].first] - 1)*(comp2[stars[i].second] - 1);
}
cout << ans << "\n";
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |