Tin học trẻ A - Vòng Khu vực miền Trung 2022



Bình luận

  • MINHPHUALT 9:45 a.m. 29 Tháng 3, 2025

    from turtle import *
    pensize(1); speed(0)
    def square(x, y, size, c):
        pu(); goto(x, y); pd(); color(c)
        begin_fill()
        for _ in range(4):  fd(size); rt(90)
        end_fill()
        color("red")
        while size >= d:
            for _ in range(4): fd(size); rt(90)
            size -= d
    n = int(input())
    d = 40
    for i in range(n, 0, -1):
        if i ==1:  square(0, 0, d, "yellow")
        else:
            L = (i-1) * d
            x, y = -L//2, L//2
            square(x, y, d * i, "yellow")
            square(x, y, d, "blue");     square(x + L, y, d, "blue")
            square(x, y - L, d, "blue"); square(x + L, y - L, d, "blue")
    ht()
    

    code b1

    • nguyendepzai2k9 2:58 p.m. 10 Tháng 10, 2024

      def build_wall(N, K, stages):
      heights = [0] * N # Initialize all columns to height 0

      for stage in stages:
          Op, Left, Right, Height = stage
          if Op == 1:  # Adding bricks
              for i in range(Left, Right + 1):
                  if heights[i] < Height:
                      heights[i] = Height
          elif Op == 2:  # Removing bricks
              for i in range(Left, Right + 1):
                  if heights[i] > Height:
                      heights[i] = Height
      
      return heights
      

      Reading input

      N, K = map(int, input().split())
      stages = [list(map(int, input().split())) for _ in range(K)]

      Processing and getting the final heights

      final_heights = build_wall(N, K, stages)

      Outputting the result

      print(" ".join(map(str, final_heights)))

      • hdhieu13dana 1:35 p.m. 21 Tháng 8, 2024

        This comment is hidden due to too much negative feedback. Click here to view it.