답안 #493515

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
493515 2021-12-11T19:36:33 Z reni 별들과 삼각형 (IZhO11_triangle) C++14
100 / 100
131 ms 14172 KB
#include<iostream>
#include<unordered_map>
#define endl '\n'
using namespace std;
unordered_map<long long, long long>mpx, mpy;
long long a[300000][2];
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    long long i,j,x,y,n, br=0;

    cin>>n;

    for(i=0;i<n;i++)
    {
        cin>>x>>y;

        a[i][0]=x; a[i][1]=y;

        mpx[x]++;
        mpy[y]++;
    }
    for(i=0;i<n;i++)
    {
        x=a[i][0]; y=a[i][1];
        if(mpx.count(x) && mpy.count(y))br+=(mpx[x]-1)*(mpy[y]-1);
    }

    cout<<br<<endl;



}

Compilation message

triangle.cpp: In function 'int main()':
triangle.cpp:13:17: warning: unused variable 'j' [-Wunused-variable]
   13 |     long long i,j,x,y,n, br=0;
      |                 ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 320 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 1 ms 204 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 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 5 ms 972 KB Output is correct
13 Correct 5 ms 968 KB Output is correct
14 Correct 6 ms 1356 KB Output is correct
15 Correct 44 ms 6540 KB Output is correct
16 Correct 46 ms 7016 KB Output is correct
17 Correct 42 ms 6624 KB Output is correct
18 Correct 51 ms 6568 KB Output is correct
19 Correct 123 ms 13360 KB Output is correct
20 Correct 95 ms 10380 KB Output is correct
21 Correct 131 ms 14172 KB Output is correct
22 Correct 116 ms 14076 KB Output is correct