Submission #99374

# Submission time Handle Problem Language Result Execution time Memory
99374 2019-03-03T07:33:42 Z kimcoding Kocka (COCI18_kocka) C++17
0 / 70
82 ms 5548 KB
#include <cstdio>
#include <cstring>
#define min(a,b) (a<b?a:b)

int *cube[4], *now[4], n;

int f(int i, int j, int val) {
	if (cube[i][j] > val || cube[i][j] == -1) return -2;
	return now[i][j] == -1  ? val : min(now[i][j], val);
}

bool solve() {
	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < n; j++) {
			if (cube[i][j] == -1 || cube[i][j] == now[i][j]) continue;
			now[i][j] = cube[i][j];
			now[i ^ 1][j] = f(i ^ 1, j, n - cube[i][j] - 1);
			int t = (i / 2 * 2 + 2) % 4;
			now[t][cube[i][j]] = f(t, cube[i][j], j);
			now[t + 1][cube[i][j]] = f(t + 1, cube[i][j], n - j - 1);
			if (now[i ^ 1][j] == -2 || now[t][cube[i][j]] == -2 || now[t + 1][cube[i][j]] == -2) 
				return false;
		}
	}
	return true;
}

int main() {
	scanf("%d", &n);
	for (int i = 0; i < 4; i++) {
		cube[i] = new int[n];
		now[i] = new int[n];
		memset(now[i], -1, sizeof(int) * n);
	}
	for (int i = 0; i < 4; i++) 
		for (int j = 0; j < n; j++) scanf("%d", &cube[i][j]);
	printf("%s\n", solve() ? "DA" : "NE");
	return 0;
}

Compilation message

kocka.cpp: In function 'int main()':
kocka.cpp:29:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
  ~~~~~^~~~~~~~~~
kocka.cpp:36:36: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   for (int j = 0; j < n; j++) scanf("%d", &cube[i][j]);
                               ~~~~~^~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 384 KB Output is correct
2 Incorrect 2 ms 512 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Incorrect 3 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 61 ms 5368 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 82 ms 5548 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 79 ms 5360 KB Output isn't correct
2 Halted 0 ms 0 KB -