A higher resolution is required to access the IDE
- 30
Learning Opportunities
This puzzle can be solved using the following concepts. Practice using these concepts and improve your skills.
Statement
Goal
In football (Soccer), the offside rule is one of the most contentious and a frequent topic of heated debate among fans. The advent of Video Assistant Referee (VAR) technology is supposed to reduce the offside uncertainty.You are tasked with implementing the VAR system for identifying offside situations, based on data supplied by both the video (screenshot at the moment the ball is played) and the human referees (players eventually considered as "actively involved" once the ball is released).
Offside position- A player is in an offside position if, at the moment the ball is released, they are nearer to the opponent's goal line than both the ball and the second last opponent (the last opponent is usually, but not necessarily, the goalkeeper).
- There is no offside position if the play (the last ball release) is a throw-in.
- The offside rule applies only to players in the opponent's half of the pitch. This makes sense since you can't be offside if you are positioned in your own camp. Only players who "transgress" the middle line and "attack" the other camp might fall in an offside trap :)
Offside offenceBeing in an offside position is not an offence in itself, but a player so positioned when the ball is played by a teammate can be judged guilty of an offside offence if they are "involved in active play" (i.e. receive the ball, interfere with an opponent, ...). In this case, the referee calls offside.
VAR dataThe input provides information (screenshot) on how all the players of
The screenshot is encoded using the characters
- If the ball is represented by lowercase
- The size of the pitch (screenshot) is
-
-
- If the ball is at the touch line, i.e. the first or the last row (Y = 0 or Y=14), then it is a throw-in.
Requested outputYou always need to print two lines:
Line 1:
Line 2:
Input
Lines 1 to 15: string of 51 characters among #.aAbBoO to represent a row of the VAR screenshot
Output
Line 1: No player in an offside position. or n player(s) in an offside position. , where n is the number of players offside.
Line 2:VAR: OFFSIDE! if an offside position should be sanctioned (offside offence). Otherwise: VAR: ONSIDE!
Line 2:
Constraints
Example
Input
################################################### #........................#........................# #.......................a#........................# #...............b.o......#........................# #######..................#..................####### #.....#......a...b.......b...........a......#.....# #.....#......b.......a..a#....b.............#.....# #..b..#........A.........#..................#.....# #.....#...........b....b.#..............a...#.....# #.....#....A.............#..................#.....# #######.......b..........#..................####### #.....................a..#.......b................# #........................#..........a.............# #........................#....b...................# ###################################################
Output
1 player(s) in an offside position. VAR: OFFSIDE!
A higher resolution is required to access the IDE