Submission #171025

# Submission time Handle Problem Language Result Execution time Memory
171025 2019-12-27T05:35:09 Z talant117408 Star triangles (IZhO11_triangle) C++17
100 / 100
529 ms 8664 KB
/*
    Code written by Talant I.D.
*/
 
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef pair <int, int> pii;
typedef tuple <int, int, int> tiii;
 
#define precision(n) fixed << setprecision(n)
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define mp make_pair
#define mt make_tuple
#define mod (int)1e9+7
#define eps (double)1e-9
#define PI 2*acos(-0.0);
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define do_not_disturb ios::sync_with_stdio(0);cin.tie(0);
#define curMod 998244353

inline bool isvowel(char ch){
    ch = tolower(ch);
    return (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u');
}
 
bool isprime(int n){
	if(n < 2 || (n % 2 == 0 && n != 2))
		return false;
	for(int i = 3; i*i <= n; i += 2) 
		if(n % i == 0) return false;
	return true;
}

int main(){
    do_not_disturb
	int n, i;
	map <int, ll> orderX, orderY;
	cin >> n;
	vector <pii> points(n+1);
	
	for(i = 1; i <= n; i++){
		cin >> points[i].first >> points[i].second;
	}
	
	for(i = 1; i <= n; i++){
		int x = points[i].first, y = points[i].second;
		orderX[x]++;
		orderY[y]++;
	}
	
	ll sum = 0;
	for(i = 1; i <= n; i++){
		int x = points[i].first, y = points[i].second;
		ll d1 = orderX[x]-1, d2 = orderY[y]-1;
		sum += d1*d2;
	}
	
	cout << sum;
	
    return 0;
} // What is to be written here?
# 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 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 292 KB Output is correct
9 Correct 2 ms 420 KB Output is correct
10 Correct 3 ms 376 KB Output is correct
11 Correct 3 ms 504 KB Output is correct
12 Correct 10 ms 1144 KB Output is correct
13 Correct 9 ms 1272 KB Output is correct
14 Correct 15 ms 1656 KB Output is correct
15 Correct 169 ms 5940 KB Output is correct
16 Correct 174 ms 6064 KB Output is correct
17 Correct 166 ms 5880 KB Output is correct
18 Correct 166 ms 6008 KB Output is correct
19 Correct 529 ms 8436 KB Output is correct
20 Correct 314 ms 7280 KB Output is correct
21 Correct 479 ms 8664 KB Output is correct
22 Correct 486 ms 8568 KB Output is correct