# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
640893 |
2022-09-15T13:39:50 Z |
andreast12 |
Kocka (COCI18_kocka) |
C++17 |
|
31 ms |
3692 KB |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fi first
#define se second
#define pb push_back
const int mod=998244353, maxn=1e5+5;
int n, a[10][maxn], ki, ka, atas, bwh, pmin[maxn], pmax[maxn], cnt[maxn], paski[maxn];
bool ans=true;
int main() {
ios_base::sync_with_stdio(false); cin.tie(NULL);
cin >> n;
for(int i=1; i<=4; i++) {
for(int j=1; j<=n; j++) cin >> a[i][j];
}
for(int i=0; i<=n; i++) pmin[i]=mod, pmax[i]=-1;
for(int i=1; i<=n; i++) {
ki=a[1][i], ka=a[2][i];
if((ki==-1)^(ka==-1)) ans=false;
if((ki==-1)&&(ka==-1)) continue;
if(ki+ka+1<=n) {
ki++, ka=n-ka;
pmin[ki]=min(pmin[ki], i);
pmin[ka+1]=min(pmin[ka+1], mod);
pmax[ki]=max(pmax[ki], i);
pmax[ka+1]=max(pmax[ka+1], -1);
cnt[ki]++, cnt[ka+1]--, paski[ki]++;
} else ans=false;
}
for(int i=1; i<=n; i++) {
cnt[i]+=cnt[i-1];
if(cnt[i]==0||cnt[i]==paski[i]) continue;
pmin[i]=min(pmin[i], pmin[i-1]);
pmax[i]=max(pmax[i], pmax[i-1]);
}
for(int i=1; i<=n; i++) {
atas=a[3][i], bwh=a[4][i];
if((atas==-1)^(bwh==-1)) ans=false;
if(atas==-1&&bwh==-1) {
if(!(pmin[i]==mod&&pmax[i]==-1)) ans=false;
else continue;
}
if(!((atas==pmin[i]-1)&&(n-pmax[i]==bwh))) ans=false;
}
cout << ((ans)?"DA":"NE") << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
31 ms |
3660 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
30 ms |
3576 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
30 ms |
3692 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |