Submission #537116

# Submission time Handle Problem Language Result Execution time Memory
537116 2022-03-14T14:44:19 Z rainboy 별자리 2 (JOI14_constellation2) C
55 / 100
9000 ms 340 KB
#include <stdio.h>
#include <string.h>

#define N	3000

int xx[N], yy[N], cc[N];

long long cross(int i, int j, int k) {
	return (long long) (xx[j] - xx[i]) * (yy[k] - yy[i]) - (long long) (xx[k] - xx[i]) * (yy[j] - yy[i]);
}

int main() {
	static int kk[3], ll[3];
	int n, i, j, k;
	long long ans;

	scanf("%d", &n);
	for (i = 0; i < n; i++)
		scanf("%d%d%d", &xx[i], &yy[i], &cc[i]);
	ans = 0;
	for (i = 0; i < n; i++)
		for (j = i + 1; j < n; j++) {
			memset(kk, 0, sizeof kk);
			memset(ll, 0, sizeof ll);
			for (k = 0; k < n; k++)
				if (k != i && k != j) {
					if (cross(i, j, k) < 0)
						kk[cc[k]]++;
					else
						ll[cc[k]]++;
				}
			ans += (long long) kk[(cc[i] + 1) % 3] * kk[(cc[i] + 2) % 3] * ll[(cc[j] + 1) % 3] * ll[(cc[j] + 2) % 3];
		}
	printf("%lld\n", ans);
	return 0;
}

Compilation message

constellation2.c: In function 'main':
constellation2.c:17:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |  scanf("%d", &n);
      |  ^~~~~~~~~~~~~~~
constellation2.c:19:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |   scanf("%d%d%d", &xx[i], &yy[i], &cc[i]);
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 296 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 300 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 292 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 3 ms 212 KB Output is correct
4 Correct 9 ms 212 KB Output is correct
5 Correct 22 ms 212 KB Output is correct
6 Correct 70 ms 212 KB Output is correct
7 Correct 70 ms 292 KB Output is correct
8 Correct 69 ms 280 KB Output is correct
9 Correct 70 ms 284 KB Output is correct
10 Correct 39 ms 212 KB Output is correct
11 Correct 69 ms 284 KB Output is correct
12 Correct 70 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1327 ms 288 KB Output is correct
2 Correct 1875 ms 300 KB Output is correct
3 Correct 2578 ms 300 KB Output is correct
4 Correct 2558 ms 300 KB Output is correct
5 Correct 8868 ms 312 KB Output is correct
6 Execution timed out 9070 ms 340 KB Time limit exceeded
7 Halted 0 ms 0 KB -