Submission #305496

#TimeUsernameProblemLanguageResultExecution timeMemory
305496phathnvKocka (COCI18_kocka)C++11
70 / 70
65 ms4216 KiB
#include <bits/stdc++.h>

#define mp make_pair
#define X first
#define Y second
#define taskname "Kocka"

using namespace std;

typedef long long ll;
typedef pair <int, int> ii;

const int N = 1e5 + 1;

int n, l[N], r[N], u[N], d[N];

void readInput(){
    scanf("%d", &n);
    for(int i = 1; i <= n; i++)
        scanf("%d", &l[i]);
    for(int i = 1; i <= n; i++)
        scanf("%d", &r[i]);
    for(int i = 1; i <= n; i++)
        scanf("%d", &u[i]);
    for(int i = 1; i <= n; i++)
        scanf("%d", &d[i]);
}

bool construct(int l[], int r[]){
    for(int i = 1; i <= n; i++)
        if (l[i] + r[i] == -2){
            l[i] = -1;
            r[i] = -1;
        } else if (min(l[i], r[i]) > -1){
            if (l[i] + r[i] >= n)
                return 0;
            l[i] = l[i] + 1;
            r[i] = n - r[i];
        } else {
            return 0;
        }
    return 1;
}

bool check(int a[], int l[], int r[]){
    for(int i = 1; i <= n; i++){
        if (a[i] == -1)
            continue;
        if (i < l[a[i]] || r[a[i]] < i)
            return 0;
    }
    return 1;
}

void solve(){
    if (!construct(l, r) || !construct(u, d)){
        printf("NE");
        return;
    }

    if (check(l, u, d) &&
        check(r, u, d) &&
        check(u, l, r) &&
        check(d, l, r))
            printf("DA");
    else
        printf("NE");
}

int main(){
    //freopen(taskname".inp", "r", stdin);
    //freopen(taskname".out", "w", stdout);
    readInput();
    solve();
    return 0;
}

Compilation message (stderr)

kocka.cpp: In function 'void readInput()':
kocka.cpp:18:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   18 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
kocka.cpp:20:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   20 |         scanf("%d", &l[i]);
      |         ~~~~~^~~~~~~~~~~~~
kocka.cpp:22:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   22 |         scanf("%d", &r[i]);
      |         ~~~~~^~~~~~~~~~~~~
kocka.cpp:24:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   24 |         scanf("%d", &u[i]);
      |         ~~~~~^~~~~~~~~~~~~
kocka.cpp:26:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   26 |         scanf("%d", &d[i]);
      |         ~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...