This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define optimiza_io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define ft first
#define sd second
#define ll long long
#define ld long double
#define ull unsigned long long
#define INF 1E5
#define LINF 1E18
using namespace std;
ll n,k,enc,ap,ans=0,ini,fin,md,maxi=0,probcol=0,probrow=0;
char mat[1003][1003];
bool mrk[1003][1003];
ll row[1003],col[1003];
int main()
{
scanf("%lld %lld",&n,&k);
for( ll i=0; i<n; i++ ){
for( ll j=0; j<n; j++ ){
scanf(" %c",&mat[i][j]);
}
}
for( ll i=0; i<n; i++ ){
for( ll j=0; j<n; j++ ){
for( ll d = 1; d <= n-1; d++ )
{
if( i + d >= n || j + d >= n ){
// printf("%lld %lld : %lld nope\n", i,j,d);
break;
}
// printf("%lld,%lld : %lld\n", i, j, d );
// enc = ap = 0;
if( mat[i][j+d] != mat[i][j] && mat[i+d][j] != mat[i][j] && mat[i+d][j+d] != mat[i][j] ){
if( !mrk[i][j] )
{
mrk[i][j] = true;
row[i]++;
col[j]++;
}
}
if( mat[i][j] != mat[i][j+d] && mat[i+d][j] != mat[i][j+d] && mat[i+d][j+d] != mat[i][j+d] ){
if( !mrk[i][j+d] )
{
mrk[i][j+d] = true;
row[i]++;
col[j+d]++;
}
}
if( mat[i][j] != mat[i+d][j] && mat[i][j+d] != mat[i+d][j] && mat[i+d][j+d] != mat[i+d][j] ){
if( !mrk[i+d][j] )
{
mrk[i+d][j] = true;
row[i+d]++;
col[j]++;
}
}
if( mat[i][j] != mat[i+d][j+d] && mat[i+d][j] != mat[i+d][j+d] && mat[i][j+d] != mat[i+d][j+d] ){
if( !mrk[i+d][j+d] )
{
mrk[i+d][j+d] = true;
row[i+d]++;
col[j+d]++;
}
}
}
}
}
ll maxicol = 0, maxirow = 0;
for( ll i=0; i<n; i++ ){
maxicol = max( maxicol, col[i] );
maxirow = max( maxirow, row[i] );
}
// printf("%lld %lld\n", maxicol, maxirow);
if( min( maxicol, maxirow ) > k )
printf("NE");
else
printf("DA");
return 0;
}
Compilation message (stderr)
sajam.cpp: In function 'int main()':
sajam.cpp:20:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%lld %lld",&n,&k);
~~~~~^~~~~~~~~~~~~~~~~~~
sajam.cpp:23:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf(" %c",&mat[i][j]);
~~~~~^~~~~~~~~~~~~~~~~~
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |