Submission #701703

# Submission time Handle Problem Language Result Execution time Memory
701703 2023-02-22T01:56:39 Z scottchou Kocka (COCI18_kocka) C++17
70 / 70
315 ms 51160 KB
#include<bits/stdc++.h>
using namespace std;
int const N = 1e5 + 5;
int l[N], r[N], top[N], bottom[N];
set<int> x[N], y[N];
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> l[i];
        if(l[i] >= 0){
            x[i].insert(l[i] + 1);
            y[l[i] + 1].insert(i);
        }
    }
    for(int i = 1; i <= n; i++){
        cin >> r[i];
        if(r[i] >= 0){
            x[i].insert(n - r[i]);
            y[n - r[i]].insert(i);
        }
    }
    for(int i = 1; i <= n; i++){
        cin >> top[i];
        if(top[i] >= 0){
            x[top[i] + 1].insert(i);
            y[i].insert(top[i] + 1);
        }
    }
    for(int i = 1; i <= n; i++){
        cin >> bottom[i];
        if(bottom[i] >= 0){
            x[n - bottom[i]].insert(i);
            y[i].insert(n - bottom[i]);
        }
    }
    bool can = 1;
    for(int i = 1; i <= n; i++){
        if(l[i] == -1 && !x[i].empty())
            can = 0;
        if(r[i] == -1 && !x[i].empty())
            can = 0;
        if(top[i] == -1 && !y[i].empty())
            can = 0;
        if(bottom[i]== -1 && !y[i].empty())
            can = 0;
        if(!can)
            break;
        if((l[i] >= 0 && *x[i].begin() != l[i] + 1) || (r[i] >= 0 && *prev(x[i].end()) != n - r[i]) || (top[i] >= 0 && *y[i].begin() != top[i] + 1) || (bottom[i] >= 0 && *prev(y[i].end()) != n - bottom[i])){
            can = 0;
            break;
        }
    }
    if(can){
        cout << "DA\n";
    }else{
        cout << "NE\n";
    }
}
# Verdict Execution time Memory Grader output
1 Correct 6 ms 10120 KB Output is correct
2 Correct 5 ms 9684 KB Output is correct
3 Correct 6 ms 10068 KB Output is correct
4 Correct 5 ms 9684 KB Output is correct
5 Correct 5 ms 10068 KB Output is correct
6 Correct 5 ms 9736 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 10116 KB Output is correct
2 Correct 6 ms 10120 KB Output is correct
3 Correct 8 ms 10068 KB Output is correct
4 Correct 6 ms 10068 KB Output is correct
5 Correct 5 ms 10068 KB Output is correct
6 Correct 5 ms 9684 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 99 ms 22420 KB Output is correct
2 Correct 258 ms 51144 KB Output is correct
3 Correct 277 ms 51160 KB Output is correct
4 Correct 26 ms 12388 KB Output is correct
5 Correct 259 ms 51020 KB Output is correct
6 Correct 289 ms 51124 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 201 ms 47148 KB Output is correct
2 Correct 29 ms 12496 KB Output is correct
3 Correct 294 ms 51064 KB Output is correct
4 Correct 232 ms 50044 KB Output is correct
5 Correct 315 ms 51148 KB Output is correct
6 Correct 255 ms 47116 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 107 ms 22348 KB Output is correct
2 Correct 29 ms 12420 KB Output is correct
3 Correct 283 ms 51088 KB Output is correct
4 Correct 291 ms 51072 KB Output is correct
5 Correct 271 ms 51124 KB Output is correct
6 Correct 30 ms 12492 KB Output is correct