Submission #166749

# Submission time Handle Problem Language Result Execution time Memory
166749 2019-12-03T15:57:08 Z Dilshod_Imomov Star triangles (IZhO11_triangle) C++17
100 / 100
544 ms 15736 KB
# include <bits/stdc++.h>
//# pragma GCC optimize("Ofast")
# define pb push_back
# define ll long long
# define fi first
# define se second
# define all(vc) vc.begin(),vc.end()
# define forn(i, n) for (int i = 0; i < int(n); i++)
# define ford(i, n) for (int i = int(n) - 1; i >= 0; i--)
# define fore(i, l, r) for (int i = int(l); i < int(r); i++)
# define in freopen("input.txt", "r", stdin)
# define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
# define time cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"
  
using namespace std;
  
const ll INF = 1e18;
const int mod = 1e9 + 7;
const ll N = 1e7 + 7; 

map < ll, ll > x, y;
pair < ll, ll > p[N];
   
int main()
{      
    speed;
    ll n;
    cin >> n;
    forn( i, n ) {
        cin >> p[i].fi >> p[i].se;
        x[ p[i].fi ]++;
        y[ p[i].se ]++;
    }
    ll ans = 0;
    forn( i, n ) {
        ans += max( 0ll, x[ p[i].fi ] - 1 ) * max( 0ll, y[ p[i].se ] - 1 );
    }
    cout << ans;
    //time;
}
# Verdict Execution time Memory Grader output
1 Correct 2 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 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 3 ms 348 KB Output is correct
10 Correct 3 ms 376 KB Output is correct
11 Correct 3 ms 504 KB Output is correct
12 Correct 11 ms 1272 KB Output is correct
13 Correct 10 ms 1400 KB Output is correct
14 Correct 16 ms 1784 KB Output is correct
15 Correct 174 ms 7968 KB Output is correct
16 Correct 193 ms 8316 KB Output is correct
17 Correct 189 ms 7928 KB Output is correct
18 Correct 166 ms 7928 KB Output is correct
19 Correct 508 ms 14780 KB Output is correct
20 Correct 339 ms 11948 KB Output is correct
21 Correct 539 ms 15612 KB Output is correct
22 Correct 544 ms 15736 KB Output is correct