Submission #171286

# Submission time Handle Problem Language Result Execution time Memory
171286 2019-12-28T07:41:49 Z makotako Kocka (COCI18_kocka) C++14
0 / 70
203 ms 9288 KB
#include<bits/stdc++.h>

#define ll long long 
#define F first
#define S second
#define pb push_back
#define pp pop_back
#define in insert
#define pii pair<int, int>
#define pll pair<ll, ll>
#define N int(1e5) + 5
#define T int(1e4) + 55
#define H int(1e3) + 55

using namespace std;

ll n, l[N], r[N], u[N], d[N], q[N], w[N], e[N], sum, num, sam, nam, used[N], used1[N];

int main() {
 	cin >> n;
 	for(int i = 1;i <= n; ++ i) {
 	 	e[i] = 1e9;
 	 	q[i] = 1e9;
 	 	w[i] = 1e9;
 	}
 	for(int i = 1;i <= n; ++ i) {
 	 	cin >> l[i];
 	    if(l[i] == -1) {
 	     	used[i] = 1;
 	     	used1[i] = 1;
 	    }
 	    else {
 			q[1 + l[i]] = i - 1;
 		 	w[1 + l[i]] = n - i;
 		 	e[i] = n - l[i] - 1;
 		}
 	}
 	for(int i = 1;i <= n; ++ i) {
 	 	cin >> r[i];
 	 	if(r[i] == -1) {
 	 	 	used[i] = 1;
 	 	 	used1[i] = 1;
 	 	}
 	 	else {
 	 		num = i - 1;
 	 		q[n - r[i]] = min(num, q[n - r[i]]);
 	 		w[n - r[i]] = min(w[n - r[i]], n - i);
 	 	}
 	 	if(e[i] < r[i] || r[i] == -1 && e[i] != 1e9) {
 	 	 	sum = 1;
 	 	}
 	}
 	for(int i = 1;i <= n; ++ i) {
		cin >> u[i];
		if(used[1 + u[i]] == 1 || q[i] < u[i] || q[i] != 1e9 && u[i] == -1) {
			sum = 2;
		}
		if(u[i] != -1)
		w[i] = min(w[i], n - u[i] - 1);
 	}
 	for(int i = 1;i <= n; ++ i) {
 	 	cin >> d[i];
 	 	if(used[n - d[i]] == 1 || u[i] == -1 && d[i] != -1 || d[i] == -1 && w[i] != 1e9 || w[i] > d[i]) {
 	 	 	sum = 3;
 	 	}
 	}
 	if(sum == 0) {
 	 	cout << "DA";
 	}
 	else {
 	 	cout << "NE";
 	}
}

Compilation message

kocka.cpp: In function 'int main()':
kocka.cpp:49:34: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
     if(e[i] < r[i] || r[i] == -1 && e[i] != 1e9) {
                       ~~~~~~~~~~~^~~~~~~~~~~~~~
kocka.cpp:55:56: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   if(used[1 + u[i]] == 1 || q[i] < u[i] || q[i] != 1e9 && u[i] == -1) {
                                            ~~~~~~~~~~~~^~~~~~~~~~~~~
kocka.cpp:63:42: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
     if(used[n - d[i]] == 1 || u[i] == -1 && d[i] != -1 || d[i] == -1 && w[i] != 1e9 || w[i] > d[i]) {
                               ~~~~~~~~~~~^~~~~~~~~~~~~
kocka.cpp:63:70: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
     if(used[n - d[i]] == 1 || u[i] == -1 && d[i] != -1 || d[i] == -1 && w[i] != 1e9 || w[i] > d[i]) {
                                                           ~~~~~~~~~~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 476 KB Output is correct
2 Incorrect 3 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 496 KB Output is correct
2 Incorrect 4 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 192 ms 9288 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 203 ms 7944 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 195 ms 9224 KB Output isn't correct
2 Halted 0 ms 0 KB -