Submission #531525

# Submission time Handle Problem Language Result Execution time Memory
531525 2022-03-01T01:53:53 Z christinelynn Star triangles (IZhO11_triangle) C++17
100 / 100
306 ms 13336 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
const ll mod = 1e9 + 7;
#pragma GCC optimize("Ofast")
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int, int>
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define sc second
#define endl '\n'
#define gl ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

int main()
{
  gl
  int n;
  cin >> n;
  
  map<int, ll> x, y;
  vi a(n, 0), b(n, 0);
  
  for(int i = 0; i < n; i++){
    cin >> a[i] >> b[i];
    x[a[i]]++;
    y[b[i]]++;
  }
  
  ll ans = 0;
  
  for(int i = 0; i < n; i++){
    ans += (x[a[i]] - 1) * (y[b[i]] - 1);
  }
  
  cout << ans << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 312 KB Output is correct
2 Correct 1 ms 308 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 312 KB Output is correct
5 Correct 1 ms 316 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 308 KB Output is correct
11 Correct 1 ms 316 KB Output is correct
12 Correct 6 ms 1100 KB Output is correct
13 Correct 6 ms 1160 KB Output is correct
14 Correct 10 ms 1600 KB Output is correct
15 Correct 101 ms 7156 KB Output is correct
16 Correct 120 ms 7440 KB Output is correct
17 Correct 105 ms 7080 KB Output is correct
18 Correct 107 ms 7108 KB Output is correct
19 Correct 288 ms 12524 KB Output is correct
20 Correct 218 ms 10212 KB Output is correct
21 Correct 306 ms 13140 KB Output is correct
22 Correct 304 ms 13336 KB Output is correct