Submission #678656

#TimeUsernameProblemLanguageResultExecution timeMemory
678656yellowtoadStar triangles (IZhO11_triangle)C++17
100 / 100
272 ms18388 KiB
#include <iostream>
#include <vector>
using namespace std;

const long long int mod = 1e5+7;
long long int n, x, y, ans;
pair<long long int, long long int> a[3000100];
vector<pair<long long int,long long int>> hx[mod+10], hy[mod+10];

int main() {
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i].first >> a[i].second;
		for (int j = 0; j < hx[((a[i].first%mod)+mod)%mod].size(); j++) {
			if (hx[((a[i].first%mod)+mod)%mod][j].first == a[i].first) {
				hx[((a[i].first%mod)+mod)%mod][j].second++;
				goto skip;
			}
		}
		hx[((a[i].first%mod)+mod)%mod].push_back({a[i].first,1});
		skip:;
		for (int j = 0; j < hy[((a[i].second%mod)+mod)%mod].size(); j++) {
			if (hy[((a[i].second%mod)+mod)%mod][j].first == a[i].second) {
				hy[((a[i].second%mod)+mod)%mod][j].second++;
				goto skipp;
			}
		}
		hy[((a[i].second%mod)+mod)%mod].push_back({a[i].second,1});
		skipp:;
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j < hx[((a[i].first%mod)+mod)%mod].size(); j++) {
			if (hx[((a[i].first%mod)+mod)%mod][j].first == a[i].first) {
				x = hx[((a[i].first%mod)+mod)%mod][j].second;
				goto skippp;
			}
		}
		skippp:;
		for (int j = 0; j < hy[((a[i].second%mod)+mod)%mod].size(); j++) {
			if (hy[((((a[i].second%mod)+mod)%mod)+mod)%mod][j].first == a[i].second) {
				y = hy[((a[i].second%mod)+mod)%mod][j].second;
				goto skipppp;
			}
		}
		skipppp:;
		ans += (x-1)*(y-1);
	}
	cout << ans << endl;
}

Compilation message (stderr)

triangle.cpp: In function 'int main()':
triangle.cpp:14:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |   for (int j = 0; j < hx[((a[i].first%mod)+mod)%mod].size(); j++) {
      |                   ~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
triangle.cpp:22:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |   for (int j = 0; j < hy[((a[i].second%mod)+mod)%mod].size(); j++) {
      |                   ~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
triangle.cpp:32:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |   for (int j = 0; j < hx[((a[i].first%mod)+mod)%mod].size(); j++) {
      |                   ~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
triangle.cpp:39:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |   for (int j = 0; j < hy[((a[i].second%mod)+mod)%mod].size(); j++) {
      |                   ~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...