CodeChef is a non-commercial competitive programming community
Login
Username (New User? Signup) Password (Forgot Password?)
Signup
Login or
Signup with
Connect
Note
  • Publicize your achievements on your Facebook Wall.
  • Challenge your friends or ask them for help.

Site Navigation

  • PRACTICE
    • Easy
    • Medium
    • Hard
    • Challenge
    • Peer
  • COMPETE
    • All Contests
    • June Long 2012
    • May Cook-Off
    • May Long 2012
  • DISCUSS
    • Forums
    • Blog
    • Wiki
    • Facebook
    • Twitter
  • COMMUNITY
    • CodeChef Meetups
    • Campus Chapters
    • Host your Contest
    • User Groups
    • CodeChef TechTalks
    • All Educational Initiatives
  • HELP
    • Frequently Asked Questions
    • FAQ for problem setters
    • Problem Setting
    • Tutorials
    • Long Contest Ranks
    • Short Contest Ranks
    • Event Calendar
  • ABOUT
    • About CodeChef
    • Team CodeChef
    • Press Room
    • CodeChef Financials
    • CodeChef Sponsorships
    • CEO's Corner
    • Contact Us
    • About Directi
Home » Compete » DreamSpark 3 » DOUBLE VISION

DOUBLE VISION

Problem code: DSPC310

  • All Submissions

All submissions for this problem are available.

The DoubleVision company designs inks and fonts that can be easily read by both humans and machines. They design their fonts on a rectangular grid. Shown below is a very simple 5x3 design for the first five digits.

.o. .o. oo. oo. o.o

o.o .o. ..o ..o o.o

o.o .o. .o. oo. ooo

o.o .o. o.. ..o ..o

.o. .o. ooo oo. ..o

The ink appears to be normal black ink, but just underneath the surface DoubleVision adds a special polymer that can be detected by an infrared scanner. A human sees the black ink but not the polymer, and a machine sees the polymer but not the black ink. The only problem is that the polymer is much more expensive than the ink, so DoubleVision wants to use as little of it as possible. They have discovered that with many fonts, each symbol can be uniquely identified by at most two pixels. By only adding the polymer to one or two pixels per symbol, they drastically lower costs while still ensuring 100% accuracy in their scanners. The font shown above has this property; pixels that uniquely identify each letter are highlighted with '#'. (There are other choices that would work as well.)

.#. .o. #o. oo. o.#

#.o .#. ..o ..o o.o

o.o .o. .o. #o. ooo

o.o .o. #.. ..o ..o

.o. .o. ooo #o. ..o

Your job is to write a program to determine if a given font has this property, and if so highlight the pixels.

The input consists of one or more test cases, followed by a line containing '0 0 0' (three zeros) that signals the end of the input. Each test case begins with a line containing three positive integers n, r, and c, separated by a space: n is the number of symbols in the font, r is the number of rows in each grid, and c is the number of columns in each grid. The next r lines contain the image of each symbol, using the exact format shown in the examples: a dot '.' represents an empty part of the grid, a lowercase 'o' represents a pixel, and adjacent grids are separated by a space. The total width of each line will be at most 79 characters (not counting end-of-line characters), and r will be at most 10. The test cases are implicitly numbered starting with 1.

For test case i, first output a line that says 'Test i'. Then determine if each symbol can be uniquely identified with one or two pixels. If not, output a line with the word 'impossible'. Otherwise, output the font in the same format except that the identifying pixels for each symbol are replaced with '#'.

In general there may be several different pixels or pixel pairs that uniquely identify a symbol. To ensure that the output is unique, we add the following definition and rules. When comparing two pixels, the topmost-leftmost pixel is the one closest to the top of the grid. If both pixels are on the same row, then the topmost-leftmost is the one closest to the left of the grid.

If one pixel will work, highlight the topmost-leftmost pixel that works. Never highlight a two-pixel solution if a one-pixel solution is possible. If two pixels are needed, highlight the pair with the topmost-leftmost pixel. If two or more pairs have the same topmost-leftmost pixel, highlight the one with the topmost-leftmost other pixel.

Input:

3 2 2

oo oo .o

o. .o o.

3 2 2

oo oo .o

o. .o oo

5 5 3

.o. .o. oo. oo. o.o

o.o .o. ..o ..o o.o

o.o .o. .o. oo. ooo

o.o .o. o.. ..o ..o

.o. .o. ooo oo. ..o

1 2 4

.o..

...o

0 0 0

Output:

Test 1

impossible

Test 2

#o #o .o

#. .# ##

Test 3

.#. .o. #o. oo. o.#

#.o .#. ..o ..o o.o

o.o .o. .o. #o. ooo

o.o .o. #.. ..o ..o

.o. .o. ooo #o. ..o

Test 4

.#..

...o


Author: ganesha
Date Added: 30-03-2010
Time Limit: 2 sec
Source Limit: 50000 Bytes
Languages: ADA, ASM, BASH, BF, C, C99 strict, CAML, CLOJ, CLPS, CPP 4.0.0-8, CPP 4.3.2, CS2, D, ERL, F#, FORT, GO, HASK, ICK, ICON, JAR, JAVA, JS, LISP clisp, LISP sbcl, LUA, NEM, NICE, PAS fpc, PAS gpc, PERL, PERL6, PHP, PIKE, PRLG, PYTH, PYTH 3.1.2, RUBY, SCALA, SCM guile, SCM qobi, ST, TEXT, WSPC


  • Submit

Comments

  • Login or Register to post a comment.

Please check your input file.

moneymachine @ 24 Apr 2010 11:22 PM

Please check your input file.

@Harshit We are pretty sure

MSP_bitmesra @ 24 Apr 2010 11:29 PM

@Harshit

We are pretty sure about the Input File.

Please check the input file

coders1122 @ 25 Apr 2010 12:04 PM

Please check the input file or atleast tell how to avoid TLE because end of input.

Im very sure the runtime of my program should be around 0.00sec.

Admin please check the input

coders1122 @ 25 Apr 2010 12:47 PM

Admin please check the input file and output file and remove unwanted EOLs.

The problem statement does not talk about any extra EOL's in the output!

@vishal Please reply!!!

coders1122 @ 25 Apr 2010 02:54 PM

@vishal

Please reply!!!

@Ravi I have replied to your

MSP_bitmesra @ 25 Apr 2010 03:19 PM

@Ravi

I have replied to your e-mail.

@LeftBrained & Others Please

MSP_bitmesra @ 25 Apr 2010 08:38 PM

@LeftBrained & Others

Please register at the Tech-Days website. link given in Guidelines in the main contest page. Many of you have not registered.

@Vishal ... were we supposed

f03nix @ 25 Apr 2010 09:08 PM

@Vishal ... were we supposed to get any mail,etc confirming the registration ?

@Antar If you have registered

MSP_bitmesra @ 25 Apr 2010 10:21 PM

@Antar

If you have registered at the Web-site. Its fine. You won't be getting any confirmation mails.

@Vishal,Zeeshan Cant find

coders1122 @ 26 Apr 2010 12:28 PM

@Vishal,Zeeshan

Cant find your contact numbers anywhere.

Do you mind to mail them by e-mail?This problem is really vexing me espescially after i know my solution is correct!:(

@Ravi Have you tried this

MSP_bitmesra @ 26 Apr 2010 04:29 PM

@Ravi

Have you tried this problem in SPOJ? I'll send you the SPOJ's link to the problem ASA I cantact Zeeshan.

can you explain the example

shadow @ 26 Apr 2010 05:55 PM

can you explain the example how it uniquely identifies the characters?

Admin: https://www.spoj.pl/pr

zahid @ 26 Apr 2010 06:07 PM

Admin:

https://www.spoj.pl/problems/DOUBLEVI/

Please

MSP_bitmesra @ 26 Apr 2010 06:20 PM

Please visit

https://www.spoj.pl/problems/DOUBLEVI/

can you give a little

shadow @ 26 Apr 2010 10:51 PM

can you give a little explanation of the example test case . How do the machine interprets the ink?

@ please tell what exactly

shadow @ 26 Apr 2010 11:05 PM

@ please tell what exactly makes two code different?

TEST1 can be #o o# .# o.  .o

shadow @ 26 Apr 2010 11:09 PM

TEST1 can be

#o o# .#

o.  .o  #.

 

What is wrong with this?

@Gunjan This is a Question

MSP_bitmesra @ 26 Apr 2010 11:25 PM

@Gunjan

This is a Question from SPOJ. Link has been given.

I know but i am not able to

shadow @ 26 Apr 2010 11:28 PM

I know but i am not able to understand the problem. How machine differentiate between different codes

@Gunjan We may provide an

MSP_bitmesra @ 26 Apr 2010 11:34 PM

@Gunjan

We may provide an editorial for the problem but that would be after our Exams end.

I would very

shadow @ 26 Apr 2010 11:55 PM

I would very much appreciate that.

But I wish I could have understood the prob so that atleast I could have tried it. :(

Anyways Great contest. :)

@Gunjan The problem could be

f03nix @ 27 Apr 2010 12:40 AM

@Gunjan

The problem could be understood from reading the test cases given. The input starts with three integers n,r,c. n here is the number of symbols in the set. r and c is the number of rows and columns required to represent a single symbol. These symbols are distributed over r input lines that follow.

Eg in the first input case :

Symbol1:

oo

o.

Symbol2:

oo

.o

etc.


Now , they could only hide the polymer under a dark spot (represented by a 0) in a symbol . You need to find the first (or first two) spots where they can hide the polymer such that the place(s) where they hide aren't dark (together at the same time) in any other symbol.

 

(this is the best how i interpret the problem ...)

SUCCESSFUL SUBMISSIONS FOR THIS PROBLEM:

Programming Competition Fetching successful submissions
Directi Go for Gold
CodeChef is a global programming communityCodeChef hosts online programming competitions
CodeChef is a non-commercial competitive programming community
  • About CodeChef
  • About Directi
  • CEO's Corner
  • C-Programming
  • Programming Languages
  • Contact Us
© 2009 Directi Group. All Rights Reserved. CodeChef uses SPOJ © by Sphere Research Labs
In order to report copyright violations of any kind, send in an email to copyright@codechef.com
CodeChef a product of Directi
The time now is:
CodeChef - A Platform for Aspiring Programmers

CodeChef was created as a platform to help programmers make it big in the world of algorithms, computer programming and programming contests. At CodeChef we work hard to revive the geek in you by hosting a programming contest at the start of the month and another smaller programming challenge in the middle of the month. We also aim to have training sessions and discussions related to algorithms, binary search, technicalities like array size and the likes. Apart from providing a platform for programming competitions, CodeChef also has various algorithm tutorials and forum discussions to help those who are new to the world of computer programming.

Practice Section - A Place to hone your 'Computer Programming Skills'

Try your hand at one of our many practice problems and submit your solution in a language of your choice. Our programming contest judge accepts solutions in over 35+ programming languages. Preparing for coding contests were never this much fun! Receive points, and move up through the CodeChef ranks. Use our practice section to better prepare yourself for the multiple programming challenges that take place through-out the month on CodeChef.

Compete - Monthly Programming Contests and Cook-offs

Here is where you can show off your computer programming skills. Take part in our 10 day long monthly coding contest and the shorter format Cook-off coding contest. Put yourself up for recognition and win great prizes. Our programming contests have prizes worth up to Rs.20,000 and $700lots more CodeChef goodies up for grabs.

Discuss

Are you new to computer programming? Do you need help with algorithms? Then be a part of CodeChef's Forums and interact with all our programmers - they love helping out other programmers and sharing their ideas. Have discussions around binary search, array size, branch-and-bound, Dijkstra's algorithm, Encryption algorithm and more by visiting the CodeChef Forums and Wiki section.

CodeChef Community

As part of our Educational initiative, we give institutes the opportunity to associate with CodeChef in the form of Campus Chapters. Hosting online programming competitions is not the only feature on CodeChef. You can also host a coding contest for your institute on CodeChef, organize an algorithm event and be a guest author on our blog.

Go For Gold

The Go for Gold Initiative was launched about a year after CodeChef was incepted, to help prepare Indian students for the ACM ICPC World Finals competition. In the run up to the ACM ICPC competition, the Go for Gold initiative uses CodeChef as a platform to train students for the ACM ICPC competition via multiple warm up contests. As an added incentive the Go for Gold initiative is also offering over Rs.8 lacs to the Indian team that beats the 29th position at the ACM ICPC world finals. Find out more about the Go for Gold and the ACM ICPC competition here.

Domain Name Registration, Web hosting, and Website Design provided by BigRock.com