Submission #879793

# Submission time Handle Problem Language Result Execution time Memory
879793 2023-11-28T06:59:52 Z binh192004 Kocka (COCI18_kocka) C++17
70 / 70
247 ms 17116 KB
#include <bits/stdc++.h>

using namespace std;

typedef long double ld;
mt19937_64 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define int long long
#define double long double
#define all(x) (x).begin(), (x).end()
#define pii pair<int, int>
#define lowbit(x) x & (-x);
#define inf 1e18
#define _inf -1e18
#define pyes cout << "YES" << endl
#define pno cout << "NO" << endl
#define inv(a) for (int& x: a) cin >> x;
#define llv(a) for (ll& x: a) cin >> x;
#define pri(a) for (int& x: a) cout << x << ' '
int const MOD = 998244353;
int const lg = 20;
int const block = 500;
// int block;
int const MAX = 1e3 + 1, N = 20;
int n, m, q, k, p;
int a[25][25];

bool Work(vector<int> l, vector<int> r, vector<int> t, vector<int> b){
      map<int, int> fortop, forbot;
      for (int i = n - 1; i >= 0; i--){
            fortop[t[i]] = i;
            forbot[b[i]] = i;
      }
//      cout << n << '\n';
      for (int i = 0; i < n; i++){
            int lef = l[i];
            int rig = r[i];
            if (lef == -1){
//                  cout << i << '\n';
                  if (rig != -1)
                        return false;
                  if (fortop.find(i) != fortop.end())
                        return false;
                  if (forbot.find(n - i - 1) != forbot.end())
                        return false;
            }
            else{
                  if (rig == -1 || rig + lef >= n)
                        return false;
                  if (fortop.find(i) != fortop.end() && fortop[i] < lef - 1)
                        return false;
                  if (forbot.find(n - i - 1) != forbot.end() && forbot[n - i - 1] < lef - 1)
                        return false;
            }
//            return true;
      }
      return true;
}
void bexuyen67() {
      cin >> n;
      vector<int> l(n);
      auto r = l;
      auto t = l;
      auto b = l;
      inv(l)
      inv(r)
      inv(t)
      inv(b)
      bool ck = 1;
      ck &= Work(l, r, t, b);
      reverse(all(t));
      reverse(all(b));
      ck &= Work(r, l, t, b);
      ck &= Work(t, b, r, l);
      reverse(all(l));
      reverse(all(r));
      ck &= Work(b, t, r, l);
      cout << (ck ? "DA" : "NE");
}

signed main() {
#ifdef binhball
      freopen("input.txt", "r", stdin);
      freopen("output.txt", "w", stdout);
#endif
      cin.tie(0)->sync_with_stdio(0);
      cout << fixed << setprecision(15);
      int t = 1;
      // cin >> t;
      while (t--)
            bexuyen67();
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 604 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 2 ms 512 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 756 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 2 ms 604 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 2 ms 604 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 202 ms 14304 KB Output is correct
2 Correct 236 ms 16956 KB Output is correct
3 Correct 226 ms 16952 KB Output is correct
4 Correct 29 ms 7780 KB Output is correct
5 Correct 224 ms 16892 KB Output is correct
6 Correct 247 ms 17108 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 196 ms 12392 KB Output is correct
2 Correct 42 ms 8044 KB Output is correct
3 Correct 239 ms 17024 KB Output is correct
4 Correct 62 ms 8024 KB Output is correct
5 Correct 227 ms 16916 KB Output is correct
6 Correct 200 ms 12408 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 227 ms 14344 KB Output is correct
2 Correct 27 ms 7844 KB Output is correct
3 Correct 225 ms 17116 KB Output is correct
4 Correct 237 ms 16904 KB Output is correct
5 Correct 228 ms 16908 KB Output is correct
6 Correct 35 ms 8016 KB Output is correct