# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
341937 | Hazem | Kocka (COCI18_kocka) | C++14 | 58 ms | 5868 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/*
ID: tmhazem1
LANG: C++14
TASK: pprime
*/
#include <bits/stdc++.h>
using namespace std;
#define S second
#define F first
#define LL long long
const int N = 2e5 + 10;
LL LINF = 100000000000000000;
LL INF = 1000000000;
int MOD = 1e9+7;
vector<pair<int,int>>vec;
int col[N][2],row[N][2];
int colval[N][2],rowval[N][2];
int main()
{
// freopen("out.txt","w",stdout);
int n;
scanf("%d",&n);
for(int i=1;i<=n*2;i++)
scanf("%d",&row[i%n?i%n:n][(i-1)/n]);
for(int i=1;i<=2*n;i++)
scanf("%d",&col[i%n?i%n:n][(i-1)/n]);
for(int i=1;i<=n;i++)
rowval[i][0] = colval[i][0] = n+1,rowval[i][1] = colval[i][1] = 0;
for(int i=1;i<=n;i++){
row[i][1] = n - row[i][1]-1;
for(int j=0;j<2;j++){
if(row[i][j]==-1||row[i][j]==n)continue;
rowval[i][0] = min(rowval[i][0],row[i][j]+1);
rowval[i][1] = max(rowval[i][1],row[i][j]+1);
colval[row[i][j]+1][0] = min(colval[row[i][j]+1][0],i);
colval[row[i][j]+1][1] = max(colval[row[i][j]+1][1],i);
}
}
for(int i=1;i<=n;i++){
col[i][1] = n-col[i][1]-1;
for(int j=0;j<2;j++){
if(col[i][j]==-1||col[i][j]==n)continue;
colval[i][0] = min(colval[i][0],col[i][j]+1);
colval[i][1] = max(colval[i][1],col[i][j]+1);
rowval[col[i][j]+1][0] = min(rowval[col[i][j]+1][0],i);
rowval[col[i][j]+1][1] = max(rowval[col[i][j]+1][1],i);
}
}
bool q = 1;
for(int i=1;i<=n;i++){
if(rowval[i][0]==n+1)rowval[i][0] = 0;
if(rowval[i][1]==0)rowval[i][1] = n+1;
if(colval[i][0]==n+1)colval[i][0] = 0;
if(colval[i][1]==0)colval[i][1] = n+1;
for(int j=0;j<2;j++){
q &= rowval[i][j] == row[i][j]+1,q &= colval[i][j]==col[i][j]+1;
}
}
puts(q?"DA":"NE");
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |