Submission #171289

# Submission time Handle Problem Language Result Execution time Memory
171289 2019-12-28T08:13:47 Z makotako Kocka (COCI18_kocka) C++14
70 / 70
233 ms 8228 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;
 	    }
 	    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;
 	 	}
 	 	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:47:34: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
     if(e[i] < r[i] || r[i] == -1 && e[i] != 1e9) {
                       ~~~~~~~~~~~^~~~~~~~~~~~~~
kocka.cpp:53: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:61: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:61: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 3 ms 504 KB Output is correct
2 Correct 3 ms 252 KB Output is correct
3 Correct 4 ms 504 KB Output is correct
4 Correct 3 ms 376 KB Output is correct
5 Correct 1 ms 376 KB Output is correct
6 Correct 3 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 504 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 4 ms 504 KB Output is correct
4 Correct 3 ms 376 KB Output is correct
5 Correct 7 ms 504 KB Output is correct
6 Correct 3 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 199 ms 6648 KB Output is correct
2 Correct 219 ms 8060 KB Output is correct
3 Correct 219 ms 8108 KB Output is correct
4 Correct 170 ms 7832 KB Output is correct
5 Correct 233 ms 8200 KB Output is correct
6 Correct 204 ms 8056 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 194 ms 5764 KB Output is correct
2 Correct 131 ms 7800 KB Output is correct
3 Correct 211 ms 8084 KB Output is correct
4 Correct 138 ms 7032 KB Output is correct
5 Correct 219 ms 8168 KB Output is correct
6 Correct 194 ms 7952 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 195 ms 6792 KB Output is correct
2 Correct 150 ms 7672 KB Output is correct
3 Correct 216 ms 8080 KB Output is correct
4 Correct 215 ms 8228 KB Output is correct
5 Correct 229 ms 8140 KB Output is correct
6 Correct 136 ms 7804 KB Output is correct