Submission #1239732

#TimeUsernameProblemLanguageResultExecution timeMemory
1239732woeLight Bulbs (EGOI24_lightbulbs)C++20
Compilation error
0 ms0 KiB
import sys

def flush():
    sys.stdout.flush()

def query(grid):
    print("?")
    for row in grid:
        print("".join(row))
    flush()
    return int(input())

def main():
    N = int(input())
    orientation = [['0'] * N for _ in range(N)]

    # Detect orientation of each lamp
    lamp_types = []
    for i in range(N):
        # Light up only one lamp at a time
        grid = [['0'] * N for _ in range(N)]
        grid[i][i] = '1'
        lit = query(grid)
        # If one lamp lights up full row, it is horizontal
        if lit == N:
            lamp_types.append('H')
        else:
            lamp_types.append('V')

    # Decide which lamps to turn on to light full grid
    result = [['0'] * N for _ in range(N)]
    for i in range(N):
        if lamp_types[i] == 'H':
            result[i][i] = '1'  # One per row
        else:
            result[i][i] = '1'  # One per column

    print("!")
    for row in result:
        print("".join(row))
    flush()

if __name__ == "__main__":
    main()

Compilation message (stderr)

Main.cpp:17:7: error: invalid preprocessing directive #Detect
   17 |     # Detect orientation of each lamp
      |       ^~~~~~
Main.cpp:20:11: error: invalid preprocessing directive #Light
   20 |         # Light up only one lamp at a time
      |           ^~~~~
Main.cpp:24:11: error: invalid preprocessing directive #If; did you mean #if?
   24 |         # If one lamp lights up full row, it is horizontal
      |           ^~
      |           if
Main.cpp:30:7: error: invalid preprocessing directive #Decide
   30 |     # Decide which lamps to turn on to light full grid
      |       ^~~~~~
Main.cpp:34:33: error: stray '#' in program
   34 |             result[i][i] = '1'  # One per row
      |                                 ^
Main.cpp:36:33: error: stray '#' in program
   36 |             result[i][i] = '1'  # One per column
      |                                 ^
Main.cpp:1:1: error: 'import' does not name a type
    1 | import sys
      | ^~~~~~
Main.cpp:1:1: note: C++20 'import' only available with '-fmodules-ts', which is not yet enabled with '-std=c++20'