# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
640885 |
2022-09-15T13:31:51 Z |
andreast12 |
Kocka (COCI18_kocka) |
C++17 |
|
33 ms |
5456 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]);
// cout << "kolom " << i << ": " << pmin[i] << ' ' << pmax[i] << '\n';
}
// for(int i=1; i<=n; i++) {
// cout << "kolom " << i << ": " << pmin[i] << ' ' << pmax[i] << '\n';
// }
for(int i=1; i<=n; i++) {
atas=a[3][i], bwh=a[4][i];
if((ki==-1)^(ka==-1)) ans=false;
if(ki==-1&&ka==-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 |
336 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 |
32 ms |
5232 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
33 ms |
5456 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
30 ms |
5324 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |