Submission #311739

# Submission time Handle Problem Language Result Execution time Memory
311739 2020-10-11T11:03:45 Z neki Kocka (COCI18_kocka) C++14
28 / 70
3 ms 544 KB
#include <bits/stdc++.h>
#define loop(i, a, b) for(long long i=a;i<b;i++)
#define pool(i, a, b) for(long long i=a-1;i>=b;i--)
#define fore(i, a) for(auto&& i:a)
#define fi first
#define se second
#define ps(a) push_back(a)
#define pb(a) pop_back(a)
#define sc scanf
#define vc vector
#define pa pair<ll, ll>
#define ll long long
#define lb lower_bound
#define ub upper_bound
#define all(a) a.begin(), a.end()
#define llmax LLONG_MAX/2
#define llmin -LLONG_MAX/2
using namespace std;
#define mn 2600
#define pa pair<ll, ll>
#define ld long double
ll l[mn], r[mn], t[mn], b[mn];
ll solve(){
    ll n;cin >> n;
    loop(i, 0, n){
        cin >> l[i];
        if(l[i]==-1) l[i]=n;
    }
    loop(i, 0, n){
        cin >> r[i];
        if(r[i]==-1) r[i]=n;
    }
    loop(i, 0, n){
        cin >> t[i];
        if(t[i]==-1) t[i]=n;
    }
    loop(i, 0, n){
        cin >> b[i];
        if(b[i]==-1) b[i]=n;
    }
    loop(i, 0, n) if(l[i]+r[i]>=n and l[i]!=n and r[i]!=n){return 0;}
    loop(i, 0, n) if(t[i]+b[i]>=n and t[i]!=n and b[i]!=n){return 0;}
    
    ll cur=n;
    loop(i, 0, n) if(cur>l[i]){
        loop(j, l[i], cur) if(t[j]<i){return 0;}
        if(t[l[i]]!=i){return 0;}
        cur=l[i];
    }
    swap(l, r);
    reverse(t, t+n);
    reverse(b, b+n);
    cur=n;
    loop(i, 0, n) if(cur>l[i]){
        loop(j, l[i], cur) if(t[j]<i){return 0;}
        if(t[l[i]]!=i){return 0;}
        cur=l[i];
    }
    swap(t, b);
    reverse(l, l+n);
    reverse(r, r+n);
    cur=n;
    loop(i, 0, n) if(cur>l[i]){
        loop(j, l[i], cur) if(t[j]<i){return 0;}
        if(t[l[i]]!=i){return 0;}
        cur=l[i];
    }
    swap(l, r);
    reverse(t, t+n);
    reverse(b, b+n);
    cur=n;
    loop(i, 0, n) if(cur>l[i]){
        loop(j, l[i], cur) if(t[j]<i){return 0;}
        if(t[l[i]]!=i){return 0;}
        cur=l[i];
    }
    return 1;
}
int main(){
    if(solve()){
        cout << "DA"<<endl;
    }
    else cout << "NE"<<endl;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 544 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -