# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
120379 |
2019-06-24T09:47:38 Z |
zeyad49 |
Kocka (COCI18_kocka) |
Java 11 |
|
519 ms |
56368 KB |
import java.io.*;
import java.util.*;
public class kocka {
public static void main(String[] args) throws IOException {
Scanner sc = new Scanner();
PrintWriter out = new PrintWriter(System.out);
int n = sc.nextInt();
int[] L = new int[n];
for (int i = 0; i < n; i++)
L[i] = sc.nextInt();
boolean ok = true;
int[] first = new int[n], last = new int[n];
Arrays.fill(first, -1);
Arrays.fill(last, -1);
for (int row = 0; row < n; row++) {
int r = sc.nextInt(), l = L[row];
if (l == -1 || r == -1) {
ok &= l == r;
} else {
r = n - r - 1;
if (l > r)
ok = false;
if (first[l] == -1)
first[l] = row;
last[l] = row;
if (first[r] == -1)
first[r] = row;
last[r] = row;
}
}
int[] U = new int[n];
for (int i = 0; i < n; i++)
U[i] = sc.nextInt();
for (int col = 0; col < n; col++) {
int d = sc.nextInt(), u = U[col];
if (d == -1 || u == -1) {
ok &= u == d;
ok &= first[col] == -1;
ok &= last[col] == -1;
} else {
d = n - d - 1;
if (u > d)
ok = false;
if (first[col] != -1 && first[col] < u) {
ok = false;
}
if (last[col] != -1 && last[col] > d)
ok = false;
}
}
out.println(ok ? "DA" : "NE");
out.close();
}
static class Scanner {
BufferedReader br;
StringTokenizer st;
Scanner() {
br = new BufferedReader(new InputStreamReader(System.in));
}
Scanner(String fileName) throws FileNotFoundException {
br = new BufferedReader(new FileReader(fileName));
}
String next() throws IOException {
while (st == null || !st.hasMoreTokens())
st = new StringTokenizer(br.readLine());
return st.nextToken();
}
String nextLine() throws IOException {
return br.readLine();
}
int nextInt() throws IOException {
return Integer.parseInt(next());
}
long nextLong() throws NumberFormatException, IOException {
return Long.parseLong(next());
}
double nextDouble() throws NumberFormatException, IOException {
return Double.parseDouble(next());
}
boolean ready() throws IOException {
return br.ready();
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
95 ms |
10424 KB |
Output is correct |
2 |
Correct |
93 ms |
10360 KB |
Output is correct |
3 |
Correct |
87 ms |
10260 KB |
Output is correct |
4 |
Correct |
100 ms |
10616 KB |
Output is correct |
5 |
Correct |
96 ms |
10332 KB |
Output is correct |
6 |
Correct |
96 ms |
10264 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
97 ms |
10500 KB |
Output is correct |
2 |
Correct |
90 ms |
10076 KB |
Output is correct |
3 |
Correct |
97 ms |
10392 KB |
Output is correct |
4 |
Correct |
90 ms |
10428 KB |
Output is correct |
5 |
Correct |
94 ms |
10412 KB |
Output is correct |
6 |
Correct |
98 ms |
10516 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
443 ms |
54616 KB |
Output is correct |
2 |
Correct |
449 ms |
56368 KB |
Output is correct |
3 |
Correct |
449 ms |
55888 KB |
Output is correct |
4 |
Correct |
390 ms |
48516 KB |
Output is correct |
5 |
Correct |
412 ms |
54392 KB |
Output is correct |
6 |
Correct |
461 ms |
52156 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
399 ms |
52680 KB |
Output is correct |
2 |
Correct |
376 ms |
47600 KB |
Output is correct |
3 |
Correct |
407 ms |
53628 KB |
Output is correct |
4 |
Correct |
386 ms |
49616 KB |
Output is correct |
5 |
Correct |
519 ms |
54056 KB |
Output is correct |
6 |
Correct |
430 ms |
53072 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
438 ms |
54412 KB |
Output is correct |
2 |
Correct |
342 ms |
45920 KB |
Output is correct |
3 |
Correct |
414 ms |
53212 KB |
Output is correct |
4 |
Correct |
407 ms |
53284 KB |
Output is correct |
5 |
Correct |
386 ms |
55960 KB |
Output is correct |
6 |
Correct |
344 ms |
46244 KB |
Output is correct |