답안 #341595

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
341595 2020-12-30T07:09:34 Z Binyomin 별들과 삼각형 (IZhO11_triangle) C++14
0 / 100
2000 ms 38520 KB
# include <bits/stdc++.h>
# define fi first
# define se second
# define int long long

using namespace std ;


int32_t main() {
    //freopen("triangles.in", "r", stdin ) ;
    //freopen("triangles.out", "w", stdout ) ;
    int n ; cin >> n ;
    map < int, int > row, col, trow, tcol ;
    vector < pair < int, int > > vc ;
    map < pair < int, int >, int > mp ;
    for( int i = 1 ; i <= n ; i ++ ) {
        int x, y ; cin >> x >> y ;
        row[x] ++ ;
        col[y] ++ ;
        vc.push_back({x, y}) ;
    }
    int ans = 0 ;
    for( int i = 0 ; i < n ; i ++ ) {
        int x = vc[i].fi, y = vc[i].se ;
        tcol[y] += row[x] - 1 ;
        trow[x] += col[y] - 1 ;
        mp[{x,y}] = row[x] + col[y] - 2 ;
    }
    for( int i = 0 ; i < n ; i ++ ) {
        int x = vc[i].fi, y = vc[i].se ;
        ans += trow[x] + tcol[y] - mp[{x,y}] ;
    }
    cout << ans / 2 << endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 496 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 2 ms 364 KB Output is correct
10 Correct 2 ms 492 KB Output is correct
11 Correct 3 ms 492 KB Output is correct
12 Correct 32 ms 2536 KB Output is correct
13 Correct 24 ms 2684 KB Output is correct
14 Correct 37 ms 3432 KB Output is correct
15 Correct 614 ms 18268 KB Output is correct
16 Correct 699 ms 19292 KB Output is correct
17 Correct 609 ms 18172 KB Output is correct
18 Correct 596 ms 18140 KB Output is correct
19 Correct 1929 ms 36296 KB Output is correct
20 Correct 1386 ms 28628 KB Output is correct
21 Execution timed out 2058 ms 38520 KB Time limit exceeded
22 Halted 0 ms 0 KB -