Submission #87303

# Submission time Handle Problem Language Result Execution time Memory
87303 2018-11-30T08:45:37 Z minhtri5302 Kocka (COCI18_kocka) C++14
28 / 70
20 ms 8816 KB
//Trương Minh Trí
#include <bits/stdc++.h>
#define FOR(i, x, y) for(int i = x; i <= y; ++i)
#define FORN(i, x, y) for(int i = x; i >= y; --i)
#define Task "Kocka"
#define maxn 10000
#define maxm
#define emlacongchuacuaanh 1302
#define pii pair <int, int>
#define pll pair <long long, long long>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define reset(x) memset(x, 0, sizeof(x));
using namespace std;
int n;
int L[maxn], R[maxn], U[maxn], D[maxn];
int a[maxn][maxn];
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
   // freopen(Task".inp", "r", stdin);
    //freopen(Task".out", "w", stdout);
    cin >> n;
    FOR(i, 1, n) cin >> L[i];
    FOR(i, 1, n) cin >> R[i];
    FOR(i, 1, n) cin >> U[i];
    FOR(i, 1, n) cin >> D[i];
    FOR(i, 1, n)
    {
        if(L[i] == 0)
        {
            if(a[i][1]==2) continue;
            if(a[i][1] == 1) return cout <<"NE", 0;
            else
            {
                a[i][1] = 2;
                continue;
            }
        }
        if(L[i] == -1)
        {
            FOR(j, 1, n) if(a[i][j] == 2) return cout <<"NE", 0; else a[i][j] = 1;
            continue;
        }
        FOR(j, 1, L[i]) if(a[i][j] == 2) return cout <<"NE", 0; else a[i][j] = 1;
        if(a[i][L[i]+1] == 1) return cout <<"NE", 0; else a[i][L[i]+1] = 2;
    }
    FOR(i, 1, n)
    {
        if(R[i] == 0)
        {
            if(a[i][n] == 2) continue;
            if(a[i][n] == 1) return cout <<"NE", 0;
            else
            {
                a[i][n] = 2;
                continue;
            }
        }
        if(R[i] == -1)
        {
            FORN(j, n, 1) if(a[i][j] == 2) return cout <<"NE", 0; else a[i][j] = 1;
            continue;
        }
        FORN(j, n, n - R[i] + 1) if(a[i][j] == 2) return cout <<"NE", 0; else a[i][j] = 1;
        if(a[i][n-R[i]] == 1) return cout <<"NE", 0; else a[i][n-R[i]] = 2;
    }
    FOR(i, 1, n)
    {
        if(U[i] == 0)
        {
            if(a[1][i]==2) continue;
            if(a[1][i] == 1) return cout <<"NE", 0;
            else
            {
                a[1][i] = 2;
                continue;
            }
        }
        if(U[i] == -1)
        {
            FOR(j, 1, n) if(a[j][i] == 2) return cout <<"NE", 0; else a[j][i] = 1;
            continue;
        }
        FOR(j, 1, U[i]) if(a[j][i] == 2) return cout <<"NE", 0; else a[j][i] = 1;
        if(a[U[i]+1][i] == 1) return cout <<"NE", 0; else a[U[i]+1][i] = 2;
    }
     FOR(i, 1, n)
    {
        if(D[i] == 0)
        {
            if(a[n][i]==2) continue;
            if(a[n][i] == 1) return cout <<"NE", 0;
            else
            {
                a[n][i] = 2;
                continue;
            }
        }
        if(D[i] == -1)
        {
            FORN(j, n, 1) if(a[j][i] == 2) return cout <<"NE", 0; else a[j][i] = 1;
            continue;
        }
        FORN(j, n, n - D[i] + 1) if(a[j][i] == 2) return cout <<"NE", 0; else a[j][i] = 1;
        if(a[n- D[i]][i] == 1) return cout <<"NE", 0; else a[n- D[i]][i] = 2;
    }
    cout << "DA";


}


























template <typename T> inline void read(T &x){char c;bool nega=0;while((!isdigit(c=getchar()))&&(c!='-'));if(c=='-'){nega=1;c=getchar();}x=c-48;while(isdigit(c=getchar())) x=x*10+c-48;if(nega) x=-x;}
template <typename T> inline void writep(T x){if(x>9) writep(x/10);putchar(x%10+48);}
template <typename T> inline void write(T x){if(x<0){putchar('-');x=-x;}writep(x);putchar(' ');}
template <typename T> inline void writeln(T x){write(x);putchar('\n');}
# Verdict Execution time Memory Grader output
1 Correct 10 ms 6264 KB Output is correct
2 Correct 20 ms 8440 KB Output is correct
3 Correct 11 ms 8440 KB Output is correct
4 Correct 20 ms 8440 KB Output is correct
5 Correct 10 ms 8440 KB Output is correct
6 Correct 20 ms 8572 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 8572 KB Output is correct
2 Correct 11 ms 8572 KB Output is correct
3 Correct 11 ms 8572 KB Output is correct
4 Correct 12 ms 8720 KB Output is correct
5 Correct 10 ms 8720 KB Output is correct
6 Correct 20 ms 8816 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 8816 KB Output is correct
2 Runtime error 15 ms 8816 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 8816 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 20 ms 8816 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -