Submission #167348

# Submission time Handle Problem Language Result Execution time Memory
167348 2019-12-07T14:13:50 Z muhammad_hokimiyon Star triangles (IZhO11_triangle) C++14
100 / 100
590 ms 13308 KB
#include <bits/stdc++.h>

#pragma GCC optimize("Ofast")

#define fi first
#define se second
#define ll long long

using namespace std;

const int N = 1e6 + 7;
const int mod = 1e9 + 7;

void solve()
{
    int n;
    map < int , ll > m,mm;
    cin >> n;
    ll ans = 0;
    vector < int > x(n);
    vector < int > y(n);
    for( int i = 0; i < n; i++ ){
        cin >> x[i] >> y[i];
        m[x[i]]++ , mm[y[i]]++;
    }
    for( int i = 0; i < n; i++ ){
        ans += (m[x[i]] - 1) * 1ll * (mm[y[i]] - 1);
    }
    cout << ans;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    //freopen( "input.txt" , "r" , stdin );
    //freopen( "output.txt" , "w" , stdout );

    int t = 1;//cin >> t;
    while( t-- ){
        solve();
    }
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 3 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 3 ms 376 KB Output is correct
11 Correct 3 ms 376 KB Output is correct
12 Correct 10 ms 1272 KB Output is correct
13 Correct 11 ms 1272 KB Output is correct
14 Correct 16 ms 1784 KB Output is correct
15 Correct 167 ms 7260 KB Output is correct
16 Correct 183 ms 7544 KB Output is correct
17 Correct 168 ms 7232 KB Output is correct
18 Correct 170 ms 7288 KB Output is correct
19 Correct 508 ms 12528 KB Output is correct
20 Correct 383 ms 10384 KB Output is correct
21 Correct 590 ms 13288 KB Output is correct
22 Correct 515 ms 13308 KB Output is correct