답안 #120543

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
120543 2019-06-24T19:09:45 Z cvele Kocka (COCI18_kocka) C++14
0 / 70
699 ms 34204 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;
    if (x == -1) {
      auto it = col.upper_bound({-1, i});
      if (it != col.end() && it->second == i) {
        ok = 0;
      }
      continue;
    }
    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});
  }
  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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 768 KB Output is correct
2 Incorrect 3 ms 256 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 768 KB Output is correct
2 Incorrect 4 ms 640 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 382 ms 9672 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 699 ms 34204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 384 ms 9652 KB Output isn't correct
2 Halted 0 ms 0 KB -