답안 #312227

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
312227 2020-10-12T19:21:28 Z vivaan_gupta 별들과 삼각형 (IZhO11_triangle) C++14
100 / 100
551 ms 9320 KB
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define endl "\n"
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define pb push_back
#define f first
#define s second
#define pi 3.141592653589793238
using namespace std;

ll gcd( ll a, ll b )
{
	if(b==0)
	{
		return a;
	}
	else
	{
		return gcd( b, a%b );
	}
}
ll lcm (ll a, ll b)
{
	return (a*b)/gcd(a,b);
}

ll power(ll a, ll b)	//a is base, b is exponent
{
	if(b==0)
		return 1;
	if(b==1)
		return a;
	if(b%2 == 1)
		return (power(a,b-1)*a)%mod;
	ll q = power(a,b/2);
	return (q*q)%mod;
}
map<int,int> x;
map<int,int> y;
int main()
{
	std::ios::sync_with_stdio(false);
	int n;
	cin>>n;
	vector<pii> v;
	set<int> se;
	for(int i =1;i<=n;i++){
		int a,b;
		cin>>a>>b;
		x[a]++;
		y[b]++;
		v.pb(mp(a,b));
		se.insert(a);
	}
	int ans = 0;
	for(auto p:v){
		int lol = x[p.first]-1;
		lol *= (y[p.second]-1);
		ans+=lol;
	}
	cout<<ans<<endl;



	return 0;
}


//Hello, this is a snippet.
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 7 ms 896 KB Output is correct
13 Correct 8 ms 1152 KB Output is correct
14 Correct 14 ms 1664 KB Output is correct
15 Correct 200 ms 5528 KB Output is correct
16 Correct 222 ms 5868 KB Output is correct
17 Correct 191 ms 5612 KB Output is correct
18 Correct 175 ms 5608 KB Output is correct
19 Correct 506 ms 9320 KB Output is correct
20 Correct 340 ms 7016 KB Output is correct
21 Correct 551 ms 9196 KB Output is correct
22 Correct 537 ms 9276 KB Output is correct