# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
341597 | Binyomin | Star triangles (IZhO11_triangle) | C++14 | 1130 ms | 25296 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
# include <bits/stdc++.h>
# define fi first
# define se second
# define int long long
using namespace std ;
int32_t main() {
ios_base::sync_with_stdio(false) ;
//freopen("triangles.in", "r", stdin ) ;
//freopen("triangles.out", "w", stdout ) ;
int n ; cin >> n ;
map < int, int > row, col, trow, tcol ;
vector < pair < int, int > > vc ;
vector < int > mp ;
for( int i = 1 ; i <= n ; i ++ ) {
int x, y ; cin >> x >> y ;
row[x] ++ ;
col[y] ++ ;
vc.push_back({x, y}) ;
}
int ans = 0 ;
for( int i = 0 ; i < n ; i ++ ) {
int x = vc[i].fi, y = vc[i].se ;
int t1 = row[x] - 1, t2 = col[y] - 1 ;
tcol[y] += t1;
trow[x] += t2;
mp.push_back(t1 + t2) ;
}
for( int i = 0 ; i < n ; i ++ ) {
int x = vc[i].fi, y = vc[i].se ;
ans += trow[x] + tcol[y] - mp[i] ;
}
cout << ans / 2 << endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |