Submission #976260

# Submission time Handle Problem Language Result Execution time Memory
976260 2024-05-06T11:09:19 Z vjudge1 Star triangles (IZhO11_triangle) C++17
100 / 100
250 ms 12628 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define lld double
#define int ll
#define usaco(fname) freopen(#fname ".in","r",stdin);freopen(#fname ".out","w",stdout);
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }
template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_type>::type> ostream& operator<<(ostream &os, const T_container &v) { os << '{'; string sep; for (const T &x : v) os << sep << x, sep = ", "; return os << '}'; }
// const ll INF = 1e18;
const int INF = 1e9;
const int mod = 1e9+7;
const lld PI = acos(-1.0);
int di[] = {1, -1, 0, 0, 1, 1, -1, -1};
int dj[] = {0, 0, 1, -1, 1, -1, 1, -1};
#define debug(x) cout << #x << ": " << x << endl;
#define add(a, b) a += b, a %= mod
#define mul(a, b) ((a % mod) * (b % mod)) % mod
#define all(x) x.begin(),x.end()

void solve() {
  int n;cin>>n;

  map<int, int> mpX, mpY;
  // x, y
  vector<pair<int, int>> points(n);
  for (int i = 0; i < n; i++) {
    cin >> points[i].first >> points[i].second;
    mpX[points[i].first]++;
    mpY[points[i].second]++;
  }

  int ans = 0;
  for (auto [x, y] : points) {
    ans += (mpX[x] - 1) * (mpY[y] - 1);
    // mpX[x]--;mpY[y]--;
  }

  cout << ans << endl;
}

int32_t main() {
  ios_base::sync_with_stdio(0);cin.tie(0);
  int t=1;
  while(t--) solve();

  return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 464 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 5 ms 1368 KB Output is correct
13 Correct 6 ms 1372 KB Output is correct
14 Correct 8 ms 1744 KB Output is correct
15 Correct 85 ms 7192 KB Output is correct
16 Correct 92 ms 7648 KB Output is correct
17 Correct 93 ms 7248 KB Output is correct
18 Correct 85 ms 7000 KB Output is correct
19 Correct 230 ms 12116 KB Output is correct
20 Correct 167 ms 9872 KB Output is correct
21 Correct 247 ms 12588 KB Output is correct
22 Correct 250 ms 12628 KB Output is correct