답안 #255069

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
255069 2020-07-31T07:48:03 Z Vladikus004 Kocka (COCI18_kocka) C++14
14 / 70
44 ms 2680 KB
#include <bits/stdc++.h>
#define inf 2e9
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;

const int N = 100000 + 3;
int n, l[N], r[N], u[N], d[N], us[N];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
    #endif // LOCAL
    cin >> n;
    for (int i = 0; i < n; i++) cin >> l[i];
    for (int i = 0; i < n; i++) cin >> r[i];
    for (int i = 0; i < n; i++) cin >> u[i];
    for (int i = 0; i < n; i++) cin >> d[i];
    for (int i = 0; i < n; i++){
        if (l[i] + r[i] >= n){
            cout << "NE";
            return 0;
        }
    }
    for (int i = 0; i < n; i++){
        if (u[i] + d[i] >= n){
            cout << "NE";
            return 0;
        }
    }
    for (int i = 0; i < n; i++){
        if ((l[i]==-1&&r[i]!=-1)||(l[i]!=-1&&r[i]==-1)||
            (u[i]==-1&&d[i]!=-1)||(u[i]!=-1&&d[i]==-1)){
            cout << "NE";
                return 0;
        }
    }
    for (int i = 0; i < n; i++){
        if (l[i] != -1 && u[l[i]] > i || u[l[i]] == -1){
            cout << "NE";
            return 0;
        }
        if (r[i] != -1 && u[n - 1 - r[i]] > i || u[n - 1 - r[i]] == -1){
            cout << "NE";
            return 0;
        }
        if (l[i] != -1 && !(l[u[l[i]]] <= l[i] && n - 1 - r[u[l[i]]] >= l[i])){
            cout << "NE";
            return 0;
        }
        if (l[i] != -1 && !(l[u[l[i]]] <= n - 1 - r[i] && n - 1 - r[u[l[i]]] >= n - 1 - r[i])){
            cout << "NE";
            return 0;
        }
    }
    cout << "DA";

}

Compilation message

kocka.cpp: In function 'int main()':
kocka.cpp:44:24: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
         if (l[i] != -1 && u[l[i]] > i || u[l[i]] == -1){
             ~~~~~~~~~~~^~~~~~~~~~~~~~
kocka.cpp:48:24: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
         if (r[i] != -1 && u[n - 1 - r[i]] > i || u[n - 1 - r[i]] == -1){
             ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 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 384 KB Output is correct
6 Correct 1 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Incorrect 1 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 41 ms 2680 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 39 ms 2680 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 44 ms 2652 KB Output isn't correct
2 Halted 0 ms 0 KB -