Submission #341597

# Submission time Handle Problem Language Result Execution time Memory
341597 2020-12-30T07:13:18 Z Binyomin Star triangles (IZhO11_triangle) C++14
100 / 100
1130 ms 25296 KB
# include <bits/stdc++.h>
# define fi first
# define se second
# define int long long

using namespace std ;


int32_t main() {
    ios_base::sync_with_stdio(false) ;
    //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 ;
    vector < 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 ;
        int t1 = row[x] - 1, t2 = col[y] - 1 ;
        tcol[y] += t1;
        trow[x] += t2;
        mp.push_back(t1 + t2) ;
    }
    for( int i = 0 ; i < n ; i ++ ) {
        int x = vc[i].fi, y = vc[i].se ;
        ans += trow[x] + tcol[y] - mp[i] ;
    }
    cout << ans / 2 << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 0 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 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 492 KB Output is correct
11 Correct 1 ms 492 KB Output is correct
12 Correct 13 ms 1768 KB Output is correct
13 Correct 12 ms 1768 KB Output is correct
14 Correct 21 ms 2792 KB Output is correct
15 Correct 338 ms 10784 KB Output is correct
16 Correct 387 ms 10996 KB Output is correct
17 Correct 415 ms 10716 KB Output is correct
18 Correct 333 ms 10716 KB Output is correct
19 Correct 1028 ms 18448 KB Output is correct
20 Correct 759 ms 14292 KB Output is correct
21 Correct 1099 ms 18820 KB Output is correct
22 Correct 1130 ms 25296 KB Output is correct