Submission #87188

# Submission time Handle Problem Language Result Execution time Memory
87188 2018-11-29T23:21:29 Z jvalsortav Kocka (COCI18_kocka) C++14
28 / 70
12 ms 6820 KB
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <cctype>
#include <ctime>
#include <utility>
#include <set>

using namespace std;

int n, x;

int square1[1010][1010], square2[1010][1010];

long long l[1010], r[1010], u[1010], d[1010];

bool inf = true;

int main() {
	
	cin >> n;
	
	for (int i = 0; i < n; i++){
		cin >> x;
		l[i] = x; // ljevo
		if (x == -1) continue;
		else{
			square1[i][x] = 1;
		}
	}
	
	for (int i = 0; i < n; i++){
		cin >> r[i]; // desno
	}
	
	/*cout << endl;
	for (int i = 0; i < n; i++){
		for (int j = 0; j < n; j++){
			cout << square1[i][j] << " "; 
		}
		cout << endl;
	}
	cout << endl;*/
	
	
	for (int i = 0; i < n; i++){
		cin >> x;
		u[i] = x; // gore
		
		if (x == -1) continue;
		else{
			square2[x][i] = 1;
		}
	}
	
	/*cout << endl;
	for (int i = 0; i < n; i++){
		for (int j = 0; j < n; j++){
			cout << square2[i][j] << " "; 
		}
		cout << endl;
	}*/
	for (int i = 0; i < n; i++){
		for (int j = 0; j < n; j++){
			if (square1[i][j] or square2[i][j]) square1[i][j] = 1;
		}
	}
	
	
	for (int i = 0; i < n; i++){
		cin >> x; // dolje
		if (x == -1) x = n;
		for (int j = n-1; j > n-x; j--){
			if (square1[j][i]){
				/*cout << j << " " << i << endl;*/
				inf = false;
				break;
			}
		}
		if (!inf) break;
	}
	if (inf){
		for (int i = 0; i < n; i++){
			x = r[i]; // desno
			if (x == -1) x = n;
			for (int j = n-1; j > n-x; j--){
				if (square1[i][j]){
					inf = false;
					break;
				}
			}
			if (!inf) break;
		}
		if (inf){
			for (int i = 0; i < n; i++){
				x = u[i]; // gore
				if (x == -1) x = n;
				for (int j = 0; j < x; j++){
					if(square1[j][i]){
						inf = false;
						break;
					}
				}
				if (!inf) break;
			}
			if (inf){
				for (int i = 0; i < n; i++){
					x = l[i]; // ljevo
					if (x == -1) x = n;
					for (int j = 0; j < x; j++){
						if (square1[i][j]){
							inf = false;
							break;
						}
					}
				}
			}
		}
	}


	/*cout << endl;
	for (int i = 0; i < n; i++){
		for (int j = 0; j < n; j++){
			cout << square1[i][j] << " "; 
		}
		cout << endl;
	}*/
	
	if (inf) cout << "DA";
	else cout << "NE";	
	
	

return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 9 ms 6648 KB Output is correct
2 Correct 8 ms 6648 KB Output is correct
3 Correct 9 ms 6688 KB Output is correct
4 Correct 9 ms 6688 KB Output is correct
5 Correct 9 ms 6696 KB Output is correct
6 Correct 8 ms 6696 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 6696 KB Output is correct
2 Correct 8 ms 6696 KB Output is correct
3 Correct 9 ms 6768 KB Output is correct
4 Correct 8 ms 6768 KB Output is correct
5 Correct 9 ms 6820 KB Output is correct
6 Correct 10 ms 6820 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 8 ms 6820 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 10 ms 6820 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 9 ms 6820 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -