답안 #341593

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
341593 2020-12-30T07:07:19 Z Binyomin 별들과 삼각형 (IZhO11_triangle) C++14
0 / 100
614 ms 131888 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;
}

Compilation message

triangle.cpp: In function 'int32_t main()':
triangle.cpp:10:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   10 |     freopen("triangles.in", "r", stdin ) ;
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
triangle.cpp:11:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   11 |     freopen("triangles.out", "w", stdout ) ;
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 614 ms 131888 KB Output isn't correct
2 Halted 0 ms 0 KB -