Submission #874965

# Submission time Handle Problem Language Result Execution time Memory
874965 2023-11-18T10:49:03 Z SevakYegoryan Star triangles (IZhO11_triangle) C++17
100 / 100
255 ms 13336 KB
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <iomanip>
#include <iterator>
#include <set>
#include <map>
#include <list>
#include <stack>
#include <queue>
#include <vector>
#include <numeric>
#include <cassert>
#include <limits>
#include <climits>
#include <unordered_set>
#include <unordered_map>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define cdap(k) cout.setf(ios::fixed | ios::showpoint); cout.precision(k);
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define pb push_back
#define ff first
#define ss second
#define mkp make_pair
#define mkt make_tuple
#define pque priority_queue
const int INF = INT_MAX;
const long long LNF = LLONG_MAX;

const int N = 300003;
int x[N], y[N];
int n;

map<int, ll> mpx, mpy;

void solve()
{
	int i, j;
	cin >> n;
	for (i = 1; i <= n; i++) {
		cin >> x[i] >> y[i];
		mpx[x[i]]++;
		mpy[y[i]]++;
	}
	
	ll ans = 0LL;
	for (i = 1; i <= n; i++) {
		ans += (mpx[x[i]] - 1LL) * (mpy[y[i]] - 1LL);
	}

	cout << ans << "\n";

	return;
}

int main()
{
	fastIO;
	int mt = 1;
	//cin >> mt;
	while(mt--) {
		solve();
	}
	return 0;
}

Compilation message

triangle.cpp: In function 'void solve()':
triangle.cpp:48:9: warning: unused variable 'j' [-Wunused-variable]
   48 |  int i, j;
      |         ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 1 ms 2244 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2392 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 5 ms 3164 KB Output is correct
13 Correct 5 ms 3164 KB Output is correct
14 Correct 8 ms 3808 KB Output is correct
15 Correct 84 ms 8528 KB Output is correct
16 Correct 96 ms 8924 KB Output is correct
17 Correct 84 ms 8532 KB Output is correct
18 Correct 83 ms 8708 KB Output is correct
19 Correct 229 ms 12776 KB Output is correct
20 Correct 162 ms 10832 KB Output is correct
21 Correct 255 ms 13336 KB Output is correct
22 Correct 243 ms 13136 KB Output is correct