답안 #17470

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
17470 2015-12-20T08:24:48 Z Namnamseo 별들과 삼각형 (IZhO11_triangle) C++
100 / 100
251 ms 8116 KB
#include <cstdio>
#include <algorithm>

using namespace std;

int cx[300010];
int cy[300010];

int px[300010];
int pxn;
int py[300010];
int pyn;

int n;

int x[300010];
int y[300010];

int main()
{
    scanf("%d",&n);
    int i;
    for(i=0;i<n;++i){
        scanf("%d%d",x+i,y+i);
        px[i]=x[i]; py[i]=y[i];
    }
    sort(px,px+n); sort(py,py+n);
    pxn=unique(px,px+n)-px;
    pyn=unique(py,py+n)-py;
    for(i=0;i<n;++i){
        x[i]=lower_bound(px,px+pxn,x[i])-px;
        y[i]=lower_bound(py,py+pyn,y[i])-py;
        ++cx[x[i]];
        ++cy[y[i]];
    }
    long long ans=0;
    for(i=0;i<n;++i){
        ans += (cx[x[i]]-1)*1ll*(cy[y[i]]-1);
    }
    printf("%lld\n",ans);
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 8116 KB Output is correct
2 Correct 0 ms 8116 KB Output is correct
3 Correct 0 ms 8116 KB Output is correct
4 Correct 0 ms 8116 KB Output is correct
5 Correct 0 ms 8116 KB Output is correct
6 Correct 0 ms 8116 KB Output is correct
7 Correct 0 ms 8116 KB Output is correct
8 Correct 0 ms 8116 KB Output is correct
9 Correct 0 ms 8116 KB Output is correct
10 Correct 0 ms 8116 KB Output is correct
11 Correct 0 ms 8116 KB Output is correct
12 Correct 3 ms 8116 KB Output is correct
13 Correct 0 ms 8116 KB Output is correct
14 Correct 9 ms 8116 KB Output is correct
15 Correct 82 ms 8116 KB Output is correct
16 Correct 90 ms 8116 KB Output is correct
17 Correct 81 ms 8116 KB Output is correct
18 Correct 77 ms 8116 KB Output is correct
19 Correct 251 ms 8116 KB Output is correct
20 Correct 145 ms 8116 KB Output is correct
21 Correct 224 ms 8116 KB Output is correct
22 Correct 230 ms 8116 KB Output is correct