Spread the word.

Share the link on social media.

Share
  • Facebook
Have an account? Sign In Now

Sign Up

Have an account? Sign In Now

Sign In

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

Sorry, you do not have permission to ask a question, You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here
Sign InSign Up

SIKSHAPATH

SIKSHAPATH Navigation

  • Home
  • Questions
  • Blog
    • Computer Science(CSE)
    • NPTEL
    • Startup
  • Shop
    • Internshala Answers
Search
Ask A Question

Mobile menu

Close
Ask A Question
  • Home
  • Questions
  • Blog
    • Computer Science(CSE)
    • NPTEL
    • Startup
  • Shop
    • Internshala Answers
Home/ Questions/Q 11516
Next

SIKSHAPATH Latest Questions

itachi
  • 3
  • 3
itachi
Asked: February 17, 20222022-02-17T20:17:00+05:30 2022-02-17T20:17:00+05:30In: Programming Language

Problem This problem was inspired by a board game called Hex, designed independently by Piet Hein and John Nash. It …

  • 3
  • 3
Problem This problem was inspired by a board game called Hex, designed independently by Piet Hein and John Nash. It …

Problem

This problem was inspired by a board game called Hex, designed independently by Piet Hein and John Nash. It has a similar idea, but does not assume you have played Hex.

This game is played on an N×NN×N board, where each cell is a hexagon. There are two players: Red side (using red stones) and Blue side (using blue stones). The board starts empty, and the two players take turns placing a stone of their color on a single cell within the overall playing board. Each player can place their stone on any cell not occupied by another stone of any color. There is no requirement that a stone must be placed beside another stone of the same color. The player to start first is determined randomly (with equal probability among the two players).

The upper side and lower sides of the board are marked as red, and the other two sides are marked as blue. For each player, the goal of the game is to connect the two sides marked with their color by forming a connected path using stones of their color. The first player to achieve this wins. Note that the four corners are considered connected to both colors.

The game ends immediately when one player wins.

Given a game state, help someone new to the game determine the status of a game board. Say one of the following:

  • Impossible: If it was impossible for two players to follow the rules and to have arrived at that game state.
  • Red wins: If the player playing the red stones has won.
  • Blue wins: If the player playing the blue stones has won.
  • Nobody wins: If nobody has yet won the game. Note that a game of Hex cannot end without a winner!

Note that in any impossible state, the only correct answer is Impossible, even if red or blue has formed a connected path of stones linking the opposing sides of the board marked by their colors.

Here is an example game on a 6×66×6 gameboard where blue won. Blue was the first player to move, and placed a blue stone at cell marked as 11. Then Red placed at cell 22, then blue at cell 33, etc. After the 1111-th stone is placed, blue wins.

 

 

 

 

 

 

 

Input

The first line of input gives the number of test cases, TT. TT test cases follow. Each test case start with the size of the side of the board, NN. This is followed by a board of NN rows and NN columns consisting of only B, R, and . characters. B indicates a cell occupied by blue stone, R indicates a cell occupied by red stone, and . indicates an empty cell.

Output

For each test case, output one line containing Case #xx: yy, where xx is the case number (starting from 11) and yy is the status of the game board. It can be “Impossible”, “Blue wins”, “Red wins”, or “Nobody wins” (excluding the quotes). Note that the judge is case-sensitive, so answers of “impossible”, “blue wins”, “red wins”, and “nobody wins” will be judged incorrect.

googlekickstart
  • 0 0 Answers
  • 680 Views
  • 0 Followers
  • 0
Answer
Share
  • Facebook

    Leave an answer
    Cancel reply

    You must login to add an answer.

    Forgot Password?

    Need An Account, Sign Up Here

    Sidebar

    store ads

    Stats

    • Questions 1k
    • Answers 1k
    • Posts 149
    • Best Answers 89
    • This Free AI Tool Translates Entire Books in Minute !
    • AI News: 🎬 Hollywood’s AI Studios, 🎓 OpenAI’s Latest Gift to Educators, 🚚 Class8 Bags $22M, 🧠 Google Gemini’s Memory Upgrade
    • AI NEWS: Legal Action Against OpenAI, $16M Paid, & Elon Musk’s Praise from Investor 🤖💰📑 | AI Boosts Cloud Seeding for Water Security 🌱💧
    • AI News: 🎬AI Video Tool Scam Exposed🤯, 🛰️ AI-Powered Drones to Ukraine 😱, Google’s $20M AI Push, Sam Altman Joins SF’s Leadership Team
    • AI News: 🤝 Biden Meets Xi on AI Talks, 💡 Xavier Niel’s Advice for Europe, ♻️ Hong Kong’s Smart Bin Revolution, 🚀 AI x Huawei

    Explore

    • Recent Questions
    • Questions For You
    • Answers With Time
    • Most Visited
    • New Questions
    • Recent Questions With Time

    Footer

    SIKSHAPATH

    Helpful Links

    • Contact
    • Disclaimer
    • Privacy Policy Notice
    • TERMS OF USE
    • FAQs
    • Refund/Cancellation Policy
    • Delivery Policy for Sikshapath

    Follow Us

    © 2021-24 Sikshapath. All Rights Reserved

    Insert/edit link

    Enter the destination URL

    Or link to existing content

      No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.