답안 #637853

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
637853 2022-09-03T12:21:00 Z NotLinux Kocka (COCI18_kocka) C++14
0 / 70
36 ms 8796 KB
/**
 * author: NotLinux
 * created: 03.09.2022 ~ 14:26:36
**/
#include <bits/stdc++.h>
using namespace std;
#define int long long
#ifdef LOCAL
    #include "/home/notlinux/debug.h"
#else
    #define debug(x...) void(37)
#endif
int n;
const int inf = -(1e9 + 7);
int md(int v , int e){
    int ss = v+e;
    if(ss < 0)ss += (n+1);
    else if(ss >= (n+1))ss-=(n+1);
    return ss;
}
void solve(){
    cin >> n;
    vector < vector < int > > sq(4 , vector < int > (n));
    for(auto &inp : sq[0])cin >> inp;
    for(auto &inp : sq[2])cin >> inp;
    for(auto &inp : sq[1])cin >> inp;
    for(auto &inp : sq[3])cin >> inp;
    for(int i = 0;i<4;i++){
        for(int j = 0;j<n;j++){
            if(sq[i][j] == -1)sq[i][j] = inf;
            int me = sq[i][j];
            int other = sq[md(i,2)][j];
            debug(i,j);
            debug(me,other);
            if((me + other) >= n){
                cout << "NE" << endl;
                return;
            }
            if(me == inf)continue;
            int left , right;
            if(i==0 or i == 1 ){
                        left = sq[md(i,1)][me];
                        right = sq[md(i,-1)][me];
                        }
            else {
                        left = sq[md(i,1)][n-me-1];
                        right = sq[md(i,-1)][n-me-1];
            }
            if(left == -1)left = inf;
            if(right == -1)right = inf;
            debug(left,right);
            if(i==0 or i == 3){
                        if(left > j or left==inf){
                            cout << "NE" << endl;
                            return;
                        }
                        else if(right > (n-j-1) or right == inf){
                            cout << "NE" << endl;
                            return;
                        }
                    }
            else {
                        if(left > (n-j-1) or left==inf){
                            cout << "NE" << endl;
                            return;
                        }
                        else if(right > j or right == inf){
                            cout << "NE" << endl;
                            return;
                        }
            }

        }
    }
    cout << "DA" << endl;
}
int32_t main(){
    ios_base::sync_with_stdio(0);cin.tie(nullptr);
    int tt=1;
//    cin >> tt;
    while(tt--)solve();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Runtime error 1 ms 460 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 31 ms 8764 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 36 ms 8796 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 34 ms 8700 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -