Submission #881878

# Submission time Handle Problem Language Result Execution time Memory
881878 2023-12-02T07:03:15 Z vjudge1 Star triangles (IZhO11_triangle) C++17
100 / 100
253 ms 19932 KB
#include <bits/stdc++.h>
using namespace std;
#define sp << " " << 
#define int long long
#define vi vector<int>
#define F(xxx,yyy) for (int xxx=1;xxx<=yyy;xxx++)
#define pii pair<int,int>
const int N = 5e5+1,inf = 1e18;

void solve() {
  int n;
  cin >> n;
  map<int,int> xc,yc;
  vector<pii> ps;
  F(i,n) {
    int a,b;
    cin >> a >> b;
    xc[a]++;
    yc[b]++;
    ps.push_back({a,b});
  }
  int ans = 0;
  for (auto it : ps) {
    ans+=(xc[it.first]-1)*(yc[it.second]-1);
  }
  cout << ans << endl;
}	
    
                  
                             
signed main() { 
  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  #ifdef Local
  freopen("in","r",stdin);
  freopen("out","w",stdout);
  #endif
  int t = 1;
  //cin >> t;
	F(i,t) solve();
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 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 1372 KB Output is correct
13 Correct 5 ms 1368 KB Output is correct
14 Correct 8 ms 2004 KB Output is correct
15 Correct 86 ms 8076 KB Output is correct
16 Correct 91 ms 8636 KB Output is correct
17 Correct 84 ms 8076 KB Output is correct
18 Correct 98 ms 7876 KB Output is correct
19 Correct 239 ms 18860 KB Output is correct
20 Correct 166 ms 12424 KB Output is correct
21 Correct 253 ms 19932 KB Output is correct
22 Correct 251 ms 19384 KB Output is correct