Submission #92445

# Submission time Handle Problem Language Result Execution time Memory
92445 2019-01-02T22:17:04 Z ltomic Kocka (COCI18_kocka) C++14
28 / 70
403 ms 66560 KB
#include <cstdio>
#include <set>
#include <cstdlib>

using namespace std;

const int MAXN = 1e5+5;

set<int> s[4][MAXN];
int l[MAXN], r[MAXN], u[MAXN], d[MAXN];
int n;

void no() {
  printf("NE\n");
  exit(0);
}

int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", l+i);
    if (l[i] == -1) continue;
    s[0][i].insert(l[i]);
    s[1][l[i]].insert(i);
    s[2][i].insert(n-l[i]-1);
    s[3][l[i]].insert(n-i-1);
  }
  for (int i = 0; i < n; ++i) {
    scanf("%d", r+i);
    if (r[i] == -1) continue;
    s[2][i].insert(r[i]);
    s[3][n-r[i]-1].insert(n-i-1);
    s[0][i].insert(n-r[i]-1);
    s[1][n-r[i]-1].insert(i);
  }
  for (int i = 0; i < n; ++i) {
    scanf("%d", u+i);
    if (u[i] == -1) continue;
    s[1][i].insert(u[i]);
    s[2][u[i]].insert(n-i-1);
    s[3][i].insert(n-u[i]-1);
    s[0][u[i]].insert(i);
  }
    for (int i = 0; i < n; ++i) {
    scanf("%d", d+i);
    if (d[i] == -1) continue;
    s[3][i].insert(d[i]);
    s[0][n-d[i]-1].insert(i);
    s[1][i].insert(n-d[i]-1);
    s[2][n-d[i]-1].insert(n-i-1);
  }
  /*for (int i = 0; i < 4; ++i) {
    for (int j = 0; j < n; ++j) {
      for (int k: s[i][j]) printf("%d ", k);
      printf("\n");
    }
    printf("\n");
  }*/

  for (int i = 0; i < n; ++i) {
    if (l[i] == -1) l[i] = n;
    s[0][i].insert(n);
    if (l[i] != *s[0][i].begin()) no();
    
    if (u[i] == -1) u[i] = n;
    s[1][i].insert(n);
    if (u[i] != *s[1][i].begin()) no();

    if (r[i] == -1) r[i] = n;
    s[2][i].insert(n);
    if (r[i] != *s[2][i].begin()) no();

    if (d[i] == -1) d[i] = n;
    s[3][i].insert(n);
    if (d[i] != *s[3][i].begin()) no();
  }

  printf("DA\n");
  return 0;
}

Compilation message

kocka.cpp: In function 'int main()':
kocka.cpp:19:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &n);
   ~~~~~^~~~~~~~~~
kocka.cpp:21:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", l+i);
     ~~~~~^~~~~~~~~~~
kocka.cpp:29:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", r+i);
     ~~~~~^~~~~~~~~~~
kocka.cpp:37:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", u+i);
     ~~~~~^~~~~~~~~~~
kocka.cpp:45:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", d+i);
     ~~~~~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 21 ms 19960 KB Output is correct
2 Correct 19 ms 19320 KB Output is correct
3 Correct 21 ms 19832 KB Output is correct
4 Correct 19 ms 19320 KB Output is correct
5 Correct 21 ms 19960 KB Output is correct
6 Correct 19 ms 19320 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 21 ms 19832 KB Output is correct
2 Correct 21 ms 20060 KB Output is correct
3 Correct 18 ms 19960 KB Output is correct
4 Correct 18 ms 20088 KB Output is correct
5 Correct 21 ms 19832 KB Output is correct
6 Correct 19 ms 19328 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 403 ms 60008 KB Output is correct
2 Runtime error 371 ms 66560 KB Execution killed with signal 9 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 361 ms 66560 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 350 ms 59896 KB Output is correct
2 Correct 78 ms 40568 KB Output is correct
3 Runtime error 311 ms 66560 KB Execution killed with signal 9 (could be triggered by violating memory limits)
4 Halted 0 ms 0 KB -