#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cmath>
#include <ctime>
#include <map>
#include <unordered_map>
#include <stack>
#include <set>
#include <unordered_set>
#include <string>
#include <cstring>
#include <bitset>
#include <limits>
#include <climits>
#include <queue>
#include <deque>
#include <list>
#include <forward_list>
#include <complex>
#include <sstream>
#include <cassert>
#include <functional>
#include <tuple>
#include <array>
#include <locale>
#include <cstdio>
#include <memory>
//#include <bits/stdc++.h>
using namespace std;
#define Fin freopen("input.txt", "r", stdin);
#define Fout freopen("output.txt", "w", stdout);
#define cp(x) cout.setf(ios::fixed); cout.precision(x);
#define rep(i, x, n) for(int i = x; i <= n; ++i)
#define add push_back
#define del pop_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#pragma warning(disable:4996)
#pragma GCC optimize("unroll-loops")
//define DEBUG
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
typedef map <int, int> mii;
typedef unordered_map <int, int> umpii;
typedef pair <int, int> pii;
typedef vector <int> lnum;
typedef vector <int> vi;
typedef vector < vector <int> > vii;
typedef priority_queue <int> pqi;
inline int nxt() { int x; scanf("%d", &x); return x; }
inline long long lnxt() { long long x; scanf("%I64d", &x); return x; }
//mt19937 gen(time(NULL));
const int base = (int)1e9;
const int N = (int)1e6 + 100;
const int MAXN = (int)1e3 + 100;
const int MOD = (int)1e9 + 7;
const int INF = INT_MAX;
const long long LL_INF = LLONG_MAX;
const long double PI = acos((ld)-1.0);
const long double EPS = 1e-8;
long long cnt = 0, ans = 0;
#define int int64_t
unordered_map <int, int> X, Y;
void solve() {
int n; cin >> n;
vector < pair <int, int> > V;
for (int i = 0; i < n; ++i) {
int x, y; cin >> x >> y;
V.add(make_pair(x, y));
X[x]++;
Y[y]++;
}
for (int i = 0; i < n; ++i) {
int x, y; tie(x, y) = V[i];
ans += max((ll)X[x] - 1, (ll)0) * max((ll)Y[y] - 1, (ll)0);
}
cout << ans << endl;
}
int32_t main() {
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//#define FREOPEN
#ifdef FREOPEN
#ifndef _MSC_VER
#define TASK ""
freopen(TASK".in", "r", stdin);
freopen(TASK".out", "w", stdout);
#endif
#endif
//Fin; Fout;
int T = 1;
//scanf("%d", &T);
for (; T; --T) solve();
#ifdef DEBUG
cerr << double(1.0 * clock() / CLOCKS_PER_SEC) << '\n';
#endif
return 0;
}
Compilation message
triangle.cpp:42:0: warning: ignoring #pragma warning [-Wunknown-pragmas]
#pragma warning(disable:4996)
triangle.cpp: In function 'long long int lnxt()':
triangle.cpp:60:57: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long long int*' [-Wformat=]
inline long long lnxt() { long long x; scanf("%I64d", &x); return x; }
~~^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
436 KB |
Output is correct |
4 |
Correct |
2 ms |
440 KB |
Output is correct |
5 |
Correct |
2 ms |
476 KB |
Output is correct |
6 |
Correct |
3 ms |
648 KB |
Output is correct |
7 |
Correct |
3 ms |
648 KB |
Output is correct |
8 |
Correct |
3 ms |
648 KB |
Output is correct |
9 |
Correct |
3 ms |
704 KB |
Output is correct |
10 |
Correct |
3 ms |
704 KB |
Output is correct |
11 |
Correct |
3 ms |
724 KB |
Output is correct |
12 |
Correct |
8 ms |
1656 KB |
Output is correct |
13 |
Correct |
8 ms |
1748 KB |
Output is correct |
14 |
Correct |
10 ms |
2376 KB |
Output is correct |
15 |
Correct |
74 ms |
8000 KB |
Output is correct |
16 |
Correct |
177 ms |
10672 KB |
Output is correct |
17 |
Correct |
78 ms |
12452 KB |
Output is correct |
18 |
Correct |
74 ms |
14612 KB |
Output is correct |
19 |
Correct |
282 ms |
27268 KB |
Output is correct |
20 |
Correct |
146 ms |
27268 KB |
Output is correct |
21 |
Correct |
199 ms |
37468 KB |
Output is correct |
22 |
Correct |
264 ms |
43992 KB |
Output is correct |