Submission #38957

# Submission time Handle Problem Language Result Execution time Memory
38957 2018-01-08T11:50:46 Z Scayre Star triangles (IZhO11_triangle) C++14
100 / 100
1039 ms 8960 KB
//
// omae wa mou shindeiru.
//

#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,sse3,sse4,popcnt,abm,mmx")

#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <iomanip>
#include <iostream>
#include <algorithm>

#define ll long long
#define ull unsigned ll
#define ioi exit(0);

#define f first
#define s second

#define inf (int)1e9 + 7

#define NFS ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0);

#define mp make_pair

#define lb(x) lower_bound(x)
#define ub(x) upper_bound(x)

#define pb push_back
#define ppb pop_back

#define endl "\n"

#define in(x) insert(x)

#define sz(x) (int)x.size()

#define all(x) x.begin(),x.end()

#define pw2(x) (1<<x) //2^x

#define sqr(x) ((x) * 1ll * (x))

using namespace std;

const int N = (int)5e5 + 7, MOD = (int)1e9 + 7;

int n;

pair <int,int> a[N];

ll ans=0;

map <int,int> x,y;

int main(){ 

	#ifdef IOI2019
		freopen ("in.txt", "r", stdin);
	#endif

	//NFS

	cin >> n;
	
	for(int i=1;i<=n;i++){
		cin >> a[i].f >> a[i].s;
		x[a[i].f]++;
		y[a[i].s]++;
	}

	for(int i=1;i<=n;i++){
		int l=x[a[i].f]-1,r=y[a[i].s]-1;
		ans+=l*r;
	}

	cout << ans << endl;

	#ifdef IOI2019
		cout << "\nTime Elapsed : " << clock () * 1.0 / CLOCKS_PER_SEC << endl;
	#endif

	ioi
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 5924 KB Output is correct
2 Correct 0 ms 5924 KB Output is correct
3 Correct 0 ms 5924 KB Output is correct
4 Correct 0 ms 5924 KB Output is correct
5 Correct 0 ms 5924 KB Output is correct
6 Correct 0 ms 5924 KB Output is correct
7 Correct 0 ms 5924 KB Output is correct
8 Correct 0 ms 5924 KB Output is correct
9 Correct 0 ms 5924 KB Output is correct
10 Correct 0 ms 5924 KB Output is correct
11 Correct 3 ms 5924 KB Output is correct
12 Correct 13 ms 6452 KB Output is correct
13 Correct 13 ms 6452 KB Output is correct
14 Correct 29 ms 6716 KB Output is correct
15 Correct 319 ms 8828 KB Output is correct
16 Correct 393 ms 8960 KB Output is correct
17 Correct 373 ms 8828 KB Output is correct
18 Correct 339 ms 8828 KB Output is correct
19 Correct 879 ms 8960 KB Output is correct
20 Correct 693 ms 8960 KB Output is correct
21 Correct 996 ms 8960 KB Output is correct
22 Correct 1039 ms 8960 KB Output is correct