Submission #17680

# Submission time Handle Problem Language Result Execution time Memory
17680 2016-01-12T06:54:16 Z Erzhann Star triangles (IZhO11_triangle) C++
100 / 100
497 ms 23496 KB
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdio>

using namespace std;

const int MaxN = int(1e6) + 123;
vector <int> v;

int a[MaxN], b[MaxN], x[MaxN], y[MaxN], n;
long long ans;

int main (){
    //freopen("triangles.in", "r", stdin);
    //freopen("triangles.out", "w", stdout);
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		cin >> x[i] >> y[i];
		v.push_back (x[i]);
		v.push_back (y[i]);
	}
	sort (v.begin(),v.end());
    v.erase (unique (v.begin(), v.end()), v.end());
	for (int i = 1; i <= n; i++) {
		x[i] = lower_bound (v.begin(), v.end(), x[i]) - v.begin() + 1;
		y[i] = lower_bound (v.begin(), v.end(), y[i]) - v.begin() + 1;
		a[x[i]]++;
		b[y[i]]++;
	}
	for(int i = 1; i <= n; i++)
		ans += (a[x[i]] - 1) * (b[y[i]] - 1);
	cout << ans;
return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 17348 KB Output is correct
2 Correct 0 ms 17348 KB Output is correct
3 Correct 0 ms 17348 KB Output is correct
4 Correct 0 ms 17348 KB Output is correct
5 Correct 0 ms 17348 KB Output is correct
6 Correct 0 ms 17348 KB Output is correct
7 Correct 0 ms 17348 KB Output is correct
8 Correct 0 ms 17348 KB Output is correct
9 Correct 0 ms 17348 KB Output is correct
10 Correct 0 ms 17348 KB Output is correct
11 Correct 2 ms 17348 KB Output is correct
12 Correct 15 ms 17480 KB Output is correct
13 Correct 16 ms 17480 KB Output is correct
14 Correct 19 ms 17480 KB Output is correct
15 Correct 166 ms 18888 KB Output is correct
16 Correct 181 ms 18888 KB Output is correct
17 Correct 140 ms 18888 KB Output is correct
18 Correct 159 ms 18888 KB Output is correct
19 Correct 474 ms 23496 KB Output is correct
20 Correct 278 ms 20424 KB Output is correct
21 Correct 497 ms 23496 KB Output is correct
22 Correct 491 ms 23496 KB Output is correct