Submission #305496

# Submission time Handle Problem Language Result Execution time Memory
305496 2020-09-23T10:58:00 Z phathnv Kocka (COCI18_kocka) C++11
70 / 70
65 ms 4216 KB
#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

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 time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 304 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 512 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 65 ms 3740 KB Output is correct
2 Correct 59 ms 4200 KB Output is correct
3 Correct 58 ms 4216 KB Output is correct
4 Correct 39 ms 3064 KB Output is correct
5 Correct 58 ms 4216 KB Output is correct
6 Correct 58 ms 4216 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 59 ms 3960 KB Output is correct
2 Correct 39 ms 3064 KB Output is correct
3 Correct 58 ms 4216 KB Output is correct
4 Correct 47 ms 3192 KB Output is correct
5 Correct 59 ms 4216 KB Output is correct
6 Correct 63 ms 3960 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 58 ms 3724 KB Output is correct
2 Correct 41 ms 3192 KB Output is correct
3 Correct 58 ms 4216 KB Output is correct
4 Correct 57 ms 4216 KB Output is correct
5 Correct 59 ms 4216 KB Output is correct
6 Correct 42 ms 3064 KB Output is correct