# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
426136 | SuckTinHock | 별들과 삼각형 (IZhO11_triangle) | C++17 | 298 ms | 33796 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define int long long
#define x first
#define y second
using namespace std;
typedef pair<int,int> Point;
Point P[300005];
int n;
int cntx[300005], cnty[300005];
void compress()
{
vector<int> A;
for (int i = 1; i <= n; ++i)
{
A.push_back(P[i].x);
A.push_back(P[i].y);
}
sort(A.begin(),A.end());
unique(A.begin(),A.end());
for (int i = 1; i <= n; ++i)
{
P[i].x = lower_bound(A.begin(),A.end(),P[i].x) - A.begin();
P[i].y = lower_bound(A.begin(),A.end(),P[i].y) - A.begin();
}
}
void xuly()
{
int res = 0;
compress();
sort(P+1,P+n+1);
vector<pair<Point,int> > PP;
for (int i = 1; i <= n; ++i)
{
PP.push_back({P[i],1});
while (i+1 <= n && P[i] == P[i+1]) ++PP.back().y, ++i;
cntx[P[i].x] += PP.back().y;
cnty[P[i].y] += PP.back().y;
}
for (pair<Point,int> T : PP)
{
Point X = T.x;
int cnt = T.y;
res += (cntx[X.x] - cnt) * (cnty[X.y] - cnt);
}
cout << res;
}
void nhap()
{
cin >> n;
for (int i = 1; i <= n; ++i) cin >> P[i].x >> P[i].y;
}
signed main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
nhap();
xuly();
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |