pythonは洛谷P 1319圧縮技術を実現する

7940 ワード

各行の0または1をbool値で表す
List = list(map(int, input().split()))
Count = 0
k = 1
Bool = False #      0 1,      bool     
while k < len(List):
    for i in range(0, List[k]):  #List[k]  0 1     
        print(int(Bool), end = '')
        Count += 1
        if Count % List[0] == 0:
            print()
    k += 1
    Bool = not Bool #     bool  List[k] ,   bool 

個人的に問題を見間違えてマトリクス転置出力を試みた・・・

```python
List = list(map(int, input().split()))
array = []#     ,      
Bool = False
k = 1
array1 = []#    ,      bool 
Count = 0
while k < len(List):
    for i in range(0, List[k]):
        array1.append(int(Bool))#    bool     
        Count += 1
        if Count % List[0] == 0:
            array.append(array1)#     ,        
            array1 = []
    k += 1
    Bool = not Bool
Count = 0
for i in range(0, List[0]):#       
    for j in range(0, List[0]):
        print(array[j][i], end = '')
        Count += 1
        if Count % List[0] == 0:
            print()