# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
311740 |
2020-10-11T11:04:20 Z |
neki |
Kocka (COCI18_kocka) |
C++14 |
|
231 ms |
8772 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 200100
#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 |
7 ms |
6528 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
7 ms |
6528 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
7 ms |
6528 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
7 ms |
6528 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
7 ms |
6528 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
8 ms |
6528 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
197 ms |
8440 KB |
Output is correct |
2 |
Correct |
231 ms |
5884 KB |
Output is correct |
3 |
Correct |
219 ms |
5880 KB |
Output is correct |
4 |
Correct |
135 ms |
7800 KB |
Output is correct |
5 |
Correct |
219 ms |
5912 KB |
Output is correct |
6 |
Correct |
221 ms |
5880 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
206 ms |
8568 KB |
Output is correct |
2 |
Correct |
138 ms |
7804 KB |
Output is correct |
3 |
Correct |
220 ms |
5752 KB |
Output is correct |
4 |
Correct |
150 ms |
7924 KB |
Output is correct |
5 |
Correct |
221 ms |
5864 KB |
Output is correct |
6 |
Correct |
207 ms |
8772 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
196 ms |
8440 KB |
Output is correct |
2 |
Correct |
139 ms |
7800 KB |
Output is correct |
3 |
Correct |
223 ms |
5880 KB |
Output is correct |
4 |
Correct |
221 ms |
5752 KB |
Output is correct |
5 |
Correct |
221 ms |
5752 KB |
Output is correct |
6 |
Correct |
141 ms |
7928 KB |
Output is correct |