Submission #166017

# Submission time Handle Problem Language Result Execution time Memory
166017 2019-11-30T08:14:21 Z Dovran Star triangles (IZhO11_triangle) C++11
100 / 100
1097 ms 9204 KB
#include <bits/stdc++.h>
#define N 400009
#define ff first
#define ss second
#define pb push_back
#define ll long long
#define pii pair <ll, ll>

using namespace std;

ll n, ans;
map<ll, ll>a, b;
pii p[N];

int main(){
	cin>>n;
	for(int i=1; i<=n; i++)
		cin>>p[i].ff>>p[i].ss, a[p[i].ff]++, b[p[i].ss]++;
	
	for(int i=1; i<=n; i++)
		ans+=max((ll)0, b[p[i].ss]-1)*max((ll)0, a[p[i].ff]-1);
	
	cout<<ans;

}
# 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 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 292 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 3 ms 376 KB Output is correct
10 Correct 14 ms 376 KB Output is correct
11 Correct 4 ms 376 KB Output is correct
12 Correct 22 ms 1144 KB Output is correct
13 Correct 23 ms 1104 KB Output is correct
14 Correct 30 ms 1540 KB Output is correct
15 Correct 331 ms 5800 KB Output is correct
16 Correct 370 ms 6032 KB Output is correct
17 Correct 330 ms 5840 KB Output is correct
18 Correct 329 ms 5832 KB Output is correct
19 Correct 1010 ms 8864 KB Output is correct
20 Correct 688 ms 7588 KB Output is correct
21 Correct 1097 ms 9200 KB Output is correct
22 Correct 1012 ms 9204 KB Output is correct