You are not logged in. Please login at www.codechef.com to post your questions!

×

BINMT – Editorial

PROBLEM LINK:

Practice
Contest

Author: Md Shahid
Tester: Arkapravo Ghosh
Editorialist: Arkapravo Ghosh

DIFFICULTY:

SIMPLE

PREREQUISITES:

2D Array, Logical AND

PROBLEM:

Given a N* N matrix A containing only 0’s and 1’s, your task is to AND every element of the matrix with the elements of its corresponding row and column and output the resulting matrix.

EXPLANATION:

The task is to AND every element of the matrix with the elements of its corresponding row and column. So, it is very clear that if a an element is 0, then the result of ANDing the elements of its corresponding row or column will be 0 also (Recall (0 AND something) = 0). So we can keep two arrays, one corresponding each column and one corresponding each row. Initially we set all the elements of the array to false. Now, if we find a 0, then we will set the corresponding row of the 0 in the row array to true and do the same with the column array also. So, now when printing the matrix, if we see that the corresponding row or column array index has a true value, then a 0 was present in the corresponding row or column, thus making the result of the AND to 0.

You can find the author's and editorialist's solution below for further implementation details.

AUTHOR'S AND EDITORIALIST'S SOLUTIONS:

Author's solution can be found here.
Editorialist’s solution can be found here

This question is marked "community wiki".

asked 25 Sep, 22:24

horsbug98's gravatar image

4★horsbug98
3236
accept rate: 21%

edited 11 Oct, 17:13

admin's gravatar image

0★admin ♦♦
19.6k349497539

toggle preview
Preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:

×1,132
×102
×75
×75
×8
×3

question asked: 25 Sep, 22:24

question was seen: 99 times

last updated: 11 Oct, 17:13