Submission #477017

# Submission time Handle Problem Language Result Execution time Memory
477017 2021-09-29T19:21:19 Z rainboy Kocka (COCI18_kocka) C
70 / 70
63 ms 5348 KB
#include <stdio.h>
#include <string.h>

#define N	100000

int main() {
	static int ll[N], rr[N], uu[N], dd[N], ii1[N], ii2[N], jj1[N], jj2[N];
	int n, i, j;

	scanf("%d", &n);
	for (i = 0; i < n; i++)
		scanf("%d", &ll[i]);
	for (i = 0; i < n; i++)
		scanf("%d", &rr[i]);
	for (j = 0; j < n; j++)
		scanf("%d", &uu[j]);
	for (j = 0; j < n; j++)
		scanf("%d", &dd[j]);
	for (i = 0; i < n; i++) {
		if ((ll[i] == -1) != (rr[i] == -1) || ll[i] + rr[i] >= n) {
			printf("NE\n");
			return 0;
		}
		if (ll[i] == -1)
			ll[i] = rr[i] = n;
		rr[i] = n - 1 - rr[i];
	}
	for (i = 0; i < n; i++) {
		if ((uu[i] == -1) != (dd[i] == -1) || uu[i] + dd[i] >= n) {
			printf("NE\n");
			return 0;
		}
		if (uu[i] == -1)
			uu[i] = dd[i] = n;
		dd[i] = n - 1 - dd[i];
	}
	for (j = 0; j < n; j++)
		ii1[j] = n, ii2[j] = -1;
	for (i = 0; i < n; i++) {
		if ((j = ll[i]) != n) {
			if (ii1[j] == -1)
				ii1[j] = i;
			ii2[j] = i;
		}
		if ((j = rr[i]) != -1) {
			if (ii1[j] == -1)
				ii1[j] = i;
			ii2[j] = i;
		}
	}
	for (j = 0; j < n; j++)
		if (ii1[j] < uu[j] || ii2[j] > dd[j]) {
			printf("NE\n");
			return 0;
		}
	for (i = 0; i < n; i++)
		jj1[i] = n, jj2[i] = -1;
	for (j = 0; j < n; j++) {
		if ((i = uu[j]) != n) {
			if (jj1[i] == -1)
				jj1[i] = j;
			jj2[i] = j;
		}
		if ((i = dd[j]) != -1) {
			if (jj1[i] == -1)
				jj1[i] = j;
			jj2[i] = j;
		}
	}
	for (i = 0; i < n; i++)
		if (jj1[i] < ll[i] || jj2[i] > rr[i]) {
			printf("NE\n");
			return 0;
		}
	printf("DA\n");
	return 0;
}

Compilation message

kocka.c: In function 'main':
kocka.c:10:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |  scanf("%d", &n);
      |  ^~~~~~~~~~~~~~~
kocka.c:12:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |   scanf("%d", &ll[i]);
      |   ^~~~~~~~~~~~~~~~~~~
kocka.c:14:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |   scanf("%d", &rr[i]);
      |   ^~~~~~~~~~~~~~~~~~~
kocka.c:16:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |   scanf("%d", &uu[j]);
      |   ^~~~~~~~~~~~~~~~~~~
kocka.c:18:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |   scanf("%d", &dd[j]);
      |   ^~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 292 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 288 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 49 ms 5144 KB Output is correct
2 Correct 46 ms 4104 KB Output is correct
3 Correct 45 ms 4036 KB Output is correct
4 Correct 36 ms 4488 KB Output is correct
5 Correct 53 ms 4104 KB Output is correct
6 Correct 48 ms 4108 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 52 ms 5344 KB Output is correct
2 Correct 38 ms 4548 KB Output is correct
3 Correct 49 ms 4064 KB Output is correct
4 Correct 47 ms 4600 KB Output is correct
5 Correct 45 ms 4048 KB Output is correct
6 Correct 47 ms 5348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 57 ms 5272 KB Output is correct
2 Correct 38 ms 4512 KB Output is correct
3 Correct 63 ms 4132 KB Output is correct
4 Correct 52 ms 4076 KB Output is correct
5 Correct 46 ms 4036 KB Output is correct
6 Correct 36 ms 4568 KB Output is correct