Submission #372344

# Submission time Handle Problem Language Result Execution time Memory
372344 2021-02-27T18:21:27 Z mariowong Star triangles (IZhO11_triangle) C++14
100 / 100
241 ms 10860 KB
#include <bits/stdc++.h>
using namespace std;

int n,l;
long long ans;
pair<int,int> a[300005];
map <int,int> ct;
int main(){
	ios::sync_with_stdio(false);
	cin >> n;
	for (int i=1;i<=n;i++){
		cin >> a[i].second >> a[i].first;
		ct[a[i].second]++;
	}
	sort(a+1,a+1+n); l=1;
	for (int i=1;i<=n;i++){
		if (i == n || a[i+1].first != a[i].first){
			for (int j=l;j<=i;j++){
				ans+=(long long)(i-l)*(long long)(ct[a[j].second]-1);	
			}
			l=i+1;
		}
	}
	cout << ans << "\n";
	return 0;
}	
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 6 ms 620 KB Output is correct
13 Correct 6 ms 876 KB Output is correct
14 Correct 8 ms 1004 KB Output is correct
15 Correct 83 ms 4716 KB Output is correct
16 Correct 92 ms 5100 KB Output is correct
17 Correct 79 ms 4844 KB Output is correct
18 Correct 81 ms 4972 KB Output is correct
19 Correct 224 ms 10112 KB Output is correct
20 Correct 159 ms 7788 KB Output is correct
21 Correct 241 ms 10732 KB Output is correct
22 Correct 235 ms 10860 KB Output is correct