Signature - Nov Cook-off Div 2

Can somebody please provide an editorial for the problem SIGNTURE.

Its a simple Brute Force since the constraints are smaller. Just check everything and see how many places differ. The main part of the code is something like this: Here A is Actual Signature Matrix and B is Given Signature Matrix. And if B[i][j] is out of bounds, its taken as ‘0’.

for(dr=-n;dr<n;dr++)
	{
		for(dc=-m;dc<m;dc++)
		{
			int a=0;
			for(i=0;i<n;i++)
			{
				for(j=0;j<m;j++)
				{
					if(A[i][j]!=((i+dr>=0&&i+dr<n&&j+dc>=0&&j+dc<m)?B[i+dr][j+dc]:'0')) a++;
				}
			}
			ans=min(ans,a);
		}
	}

Code: CodeChef: Practical coding for everyone

P.S. There’s a lot of unnecessary lines in there 'cause initially, I thought it will be more complex. But it’s just a brute force.

2 Likes

Thanks! I kept trying for long and it turns out to be this.