| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 1239746 | woe | Light Bulbs (EGOI24_lightbulbs) | Pypy 3 | 135 ms | 48832 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 (stdout)
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
