Submission #120537

# Submission time Handle Problem Language Result Execution time Memory
120537 2019-06-24T18:50:39 Z cvele Kocka (COCI18_kocka) C++14
0 / 70
672 ms 34084 KB
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <iomanip>
#include <bitset>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>

using namespace std;

typedef pair <int, int> ii;

struct cmp1 {
  bool operator()(const ii &a, const ii &b) {
    if (a.first != b.first) {
      return a.first < b.first;
    }
    return a.second < b.second;
  }
};

struct cmp2 {
  bool operator()(const ii &a, const ii &b) {
    if (a.second != b.second) {
      return a.second < b.second;
    }
    return a.first < b.first;
  }
};

int n;
bool ok = 1;
set <ii, cmp1> row;
set <ii, cmp2> col;

int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int x;
    cin >> x;
    if (x != -1) {
      row.insert({i, x + 1});
      col.insert({i, x + 1});
    }
  }
  for (int i = 1; i <= n; i++) {
    int x;
    cin >> x;
    if (x == -1) {
      auto it = row.upper_bound({i, -1});
      if (it != row.end() && it->first == i) {
        ok = 0;
      }
      continue;
    }
    x = n - x;
    auto it = row.upper_bound({i, x});
    if (it != row.end() && it->first == i) {
      ok = 0;
    }
    row.insert({i, x});
    col.insert({i, x});
  }
  for (int i = 1; i <= n; i++) {
    int x;
    cin >> x; x++;
    if (x == -1) {
      auto it = col.upper_bound({-1, i});
      if (it != col.end() && it->second == i) {
        ok = 0;
      }
      continue;
    }
    auto it = col.upper_bound({x, i});
    if (it != col.end() && it->second == i) {
      ok = 0;
    }
    row.insert({x, i});
    col.insert({x, i});
  }
  for (int i = 1; i <= n; i++) {
    int x;
    cin >> x;
    if (x == -1) {
      auto it = col.upper_bound({-1, i});
      if (it != col.end() && it->second == i) {
        ok = 0;
      }
      continue;
    }
    x = n - x;
    auto it = col.upper_bound({x, i});
    if (it != col.end() && it->second == i) {
      ok = 0;
    }
    row.insert({x, i});
    col.insert({x, i});
  }
  if (ok) {
    cout << "DA" << endl;
  } else {
    cout << "NE" << endl;
  }
  return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 640 KB Output is correct
2 Incorrect 3 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 640 KB Output is correct
2 Incorrect 4 ms 740 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 396 ms 12984 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 672 ms 34084 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 411 ms 13080 KB Output isn't correct
2 Halted 0 ms 0 KB -