Submission #320029

# Submission time Handle Problem Language Result Execution time Memory
320029 2020-11-07T10:40:44 Z kingfran1907 Star triangles (IZhO11_triangle) C++14
100 / 100
469 ms 12260 KB
#include <bits/stdc++.h>
#define X first
#define Y second

using namespace std;
typedef long long llint;

const int maxn = 3e5+10;
const int base = 31337;
const int mod = 1e9+7;
const int inf = 0x3f3f3f3f;
const int logo = 20;
const int off = 1 << logo;
const int treesiz = off << 1;

int n;
int x[maxn], y[maxn];
map<int, int> xs, ys;

int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d%d", x+i, y+i);
		xs[x[i]]++;
		ys[y[i]]++;
	}
	
	llint sol = 0;
	for (int i = 0; i < n; i++) {
		sol += (llint)(xs[x[i]] - 1) * (ys[y[i]] - 1);
	}
	printf("%lld\n", sol);
	return 0;
}

Compilation message

triangle.cpp: In function 'int main()':
triangle.cpp:21:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   21 |  scanf("%d", &n);
      |  ~~~~~^~~~~~~~~~
triangle.cpp:23:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   23 |   scanf("%d%d", x+i, y+i);
      |   ~~~~~^~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 492 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 8 ms 1004 KB Output is correct
13 Correct 9 ms 1132 KB Output is correct
14 Correct 11 ms 1408 KB Output is correct
15 Correct 154 ms 6244 KB Output is correct
16 Correct 150 ms 6576 KB Output is correct
17 Correct 142 ms 6340 KB Output is correct
18 Correct 153 ms 6172 KB Output is correct
19 Correct 354 ms 11656 KB Output is correct
20 Correct 281 ms 9316 KB Output is correct
21 Correct 400 ms 12260 KB Output is correct
22 Correct 469 ms 12260 KB Output is correct