Submission #105126

# Submission time Handle Problem Language Result Execution time Memory
105126 2019-04-10T15:40:57 Z leonarda Kocka (COCI18_kocka) C++14
70 / 70
66 ms 4344 KB
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair<int, int> pi;
typedef long long int lint;
const int inf = 0x3f3f3f3f;
const int maxn = 1e5 + 10;

int n;
int l[maxn], r[maxn], d[maxn], u[maxn];

int main ()
{
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	
	cin >> n;
	for(int i = 0; i < n; ++i) 
		cin >> l[i];
	for(int i = 0; i < n; ++i)
		cin >> r[i];
	for(int i = 0; i < n; ++i)
		cin >> u[i];
	for(int i = 0; i < n; ++i)
		cin >> d[i];
	
	for(int i = 0; i < n; ++i) {
//		cout << i << endl;
		
		if(d[i] != -1)
			if(l[n - 1 - d[i]] == -1 or r[n - 1 - d[i]] == -1)
				return cout << "NE", 0;
		if(u[i] != -1)
			if(l[u[i]] == -1 or r[u[i]] == -1)
				return cout << "NE", 0;
		if(l[i] != -1)
			if(d[l[i]] == -1 or u[l[i]] == -1)
				return cout << "NE", 0;
		if(r[i] != -1)
			if(d[n - 1 - r[i]] == -1 or u[n - 1 - r[i]] == -1)
				return cout << "NE", 0;
				
		if(l[i] == -1 and r[i] != -1)
			return cout << "NE", 0;
		if(r[i] == -1 and l[i] != -1)
			return cout << "NE", 0;
		if(d[i] == -1 and u[i] != -1)
			return cout << "NE", 0;
		if(u[i] == -1 and d[i] != -1)
			return cout << "NE", 0;
			
		if(d[i] + u[i] >= n or l[i] + r[i] >= n)
			return cout << "NE", 0;

			
		if(u[i] != -1)
			if(l[u[i]] > i or r[u[i]] > n - i - 1)
				return cout << "NE", 0;
		if(d[i] != -1)
			if(l[n - 1 - d[i]] > i or r[n - 1 - d[i]] > n - i - 1)
				return cout << "NE", 0;
		if(l[i] != -1)
			if(d[l[i]] > n - i - 1 or u[l[i]] > i)
				return cout << "NE", 0;
		if(r[i] != -1)
			if(u[n - 1 - r[i]] > i or d[n - 1 - r[i]] > n - i - 1)
				return cout << "NE", 0;
	}

	cout << "DA";
return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 3 ms 436 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 48 ms 3724 KB Output is correct
2 Correct 52 ms 4276 KB Output is correct
3 Correct 66 ms 4248 KB Output is correct
4 Correct 47 ms 3192 KB Output is correct
5 Correct 48 ms 4216 KB Output is correct
6 Correct 61 ms 4344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 50 ms 3936 KB Output is correct
2 Correct 36 ms 3064 KB Output is correct
3 Correct 46 ms 4216 KB Output is correct
4 Correct 49 ms 3320 KB Output is correct
5 Correct 47 ms 4188 KB Output is correct
6 Correct 55 ms 3960 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 48 ms 3832 KB Output is correct
2 Correct 34 ms 3064 KB Output is correct
3 Correct 44 ms 4216 KB Output is correct
4 Correct 50 ms 4216 KB Output is correct
5 Correct 44 ms 4216 KB Output is correct
6 Correct 38 ms 3064 KB Output is correct