F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Gokigen Naname

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 259    Accepted Submission(s): 43


Problem Description
Gokigen Naname is a Japanese puzzle game played on a square grid in which numbers in circles appear at some of the intersections on the grid.

The objective is to draw diagonal lines in each cell of the grid, such that the number in each circle equals the number of lines extending from that circle. Additionally, it is forbidden for the diagonal lines to form an enclosed loop.

    

The first figure shows the start position of a puzzle. The second figure shows the solution to the same puzzle. A Gokigen Naname puzzle always has exactly one solution.
 

Input
The first line of the input contains a single integer n (2 <= n <= 7), the number of cells along each of the sides in the square grid. Then follow n + 1 lines containing the contents of the intersections of the grid cells. Each such line will contain a string of n+1 characters, either a digit between 0 and 4, inclusive, or a period ('.') indicating that there is no number at this intersection (arbitrarily many lines may connect to it).
 

Output
The output should contain n lines, each line containing exactly n characters. Each character should either be a slash or a backslash, denoting how the corresponding grid cell is filled.
 

Sample Input
3 1.1. ...0 .3.. ..2. 5 .21... ..33.0 ...... ..33.. 0..33. ....11
 

Sample Output
\// \\\ /\/ /\\// //\\\ \\\// \/\\/ ///\\
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-06-29 10:31:08, Gzip enabled