Problem:


Score: 600 points

Problem Statement

AtCoder's head office consists of N rooms numbered 1 to N. For any two rooms, there is a direct passage connecting these rooms.

For security reasons, Takahashi the president asked you to set a level for every passage, which is a positive integer and must satisfy the following condition:

For each room i\ (1 \leq i \leq N), if we leave Room i, pass through some passages whose levels are all equal and get back to Room i, the number of times we pass through a passage is always even.

Your task is to set levels to the passages so that the highest level of a passage is minimized.

Constraints

N is an integer between 2 and 500 (inclusive).

Input

Input is given from Standard Input in the following format:

N

Output

Print one way to set levels to the passages so that the objective is achieved, as follows:

a_{1,2} a_{1,3} ... a_{1,N}
a_{2,3} ... a_{2,N}
.
.
.
a_{N-1,N}

Here a_{i,j} is the level of the passage connecting Room i and Room j.

If there are multiple solutions, any of them will be accepted.

Sample Input 1

3

Sample Output 1

1 2
1

The following image describes this output:

For example, if we leave Room 2, traverse the path 2 \to 3 \to 2 \to 3 \to 2 \to 1 \to 2 while only passing passages of level 1 and get back to Room 2, we pass through a passage six times.



Sample input:
3


Sample output:
1 2
1

Submission status: Wrong Answer

Solution code:
print((int(input())+1)//2)

Submission status: Wrong Answer

Solution code:
N=int(input())

ans=[]
for i in range(N-1):
  tmp=[]
  for j in range(i+1,N):
    if i%2 != j%2:
      tmp.append(1)
    else:
      tmp.append((i+2)//2+1)
  ans.append(tmp)
  
for i in range(N-1):
  print(*ans[i])

Submission status: Wrong Answer

Solution code:
N=int(input())

ans=[]
for i in range(N-1):
  tmp=[]
  for j in range(i+1,N):
    if i%2 != j%2:
      tmp.append(1)
    else:
      tmp.append(i+2)
  ans.append(tmp)
  
for i in range(N-1):
  print(*ans[i])

Submission status: Wrong Answer

Solution code:
n = int(input())
for i in range(n - 1):
    for j in range(i + 1, n):
        print((i ^ j) &- (i ^ j).bit_length(), end=" ")
    print()

Submission status: Wrong Answer

Solution code:
n = int(input())
for i in range(n - 1):
    for j in range(i + 1, n):
        print((i ^ j) & (-1 * (i ^ j)).bit_length(), end=" ")
    print()

Submission status: Wrong Answer

Solution code:
n = int(input())
for i in range(n - 1):
    for j in range(i + 1, n):
        print((i ^ j) & -(i ^ j).bit_length(), end=" ")
    print()

Submission status: Wrong Answer

Solution code:
#二部グラフにできるのか
#同じやつは1で違うやつは2で
#頂点の偶奇で同じかを分ける
n=int(input())
for i in range(n-1):
    ans=[]
    for j in range(n-1-i):
        ans.append(2 if j%2 else 1)
    print(" ".join(map(str,ans)))

Submission status: Wrong Answer

Solution code:
N = int(input())

if N % 2 == 0:
    ans = []
    for i in range(N - 1):
        ans.clear()
        for j in range(i + 1, N):
            if (j - i) % 2 == 1:
                ans.append(1)
            else:
                ans.append(2)
        print(*ans)
else:
    ans = []
    for i in range(N - 1):
        ans.clear()
        for j in range(i + 1, N):
            if i == 0 and j == N - 1:
                ans.append(2)
            elif (j - i) % 2 == 1:
                ans.append(1)
            else:
                ans.append(2)
        print(*ans)

Submission status: Wrong Answer

Solution code:
import math
n = int(input())
for i in range(n):
  ans = ""
  for j in range(i + 1, n):
    ixorj = i ^ j
    cnt = 1
    while ixorj >= 2:
      cnt += 1
      ixorj //= 2
    ans += str(cnt)
    if j != n-1:
      ans += " "
  if i != n-2:
    ans += "\n"
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
half = -int(-N/2)

query = [[0]*N for _ in range(N-1)]
for i in range(N-1):
    for j in range(i+1, N):
        if i%2==j%2:
            if i%2==1:
                query[i][j] = ((j-i-1)//2%2)+2
            else:
                query[i][j] = ((j-i-1)//2%2)+2
        else:
            query[i][j] = 1

for i in range(N-1):
    print(*[x for x in  query[i] if x!=0])

Submission status: Wrong Answer

Solution code:
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
half = -int(-N/2)

query = [[0]*N for _ in range(N-1)]
for i in range(N-1):
    for j in range(i+1, N):
        if i%2==j%2:
            if i%2==1:
                query[i][j] = ((j-i-1)//2)+2
            else:
                query[i][j] = ((j-i-1)//2)+2
        else:
            query[i][j] = 1

for i in range(N-1):
    print(*[x for x in  query[i] if x!=0])

Submission status: Wrong Answer

Solution code:
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
half = -int(-N/2)

query = [[0]*N for _ in range(N-1)]
for i in range(N-1):
    for j in range(i+1, N):
        if i%2==j%2:
            if i%2==1:
                query[i][j] = ((j-i)//2%2)+2
            else:
                query[i][j] = ((j-i)//2%4)+2
        else:
            query[i][j] = 1

for i in range(N-1):
    print(*[x for x in  query[i] if x!=0])

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [[0 for _ in range(N+1)] for _ in range(N+1)]
for i in range(1,N):
    for j in range(i+1,N+1):
        A[i][j] = i
for i in range(1,N):
    B = A[i][i+1:N+1]
    print(*B)

Submission status: Wrong Answer

Solution code:
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
half = -int(-N/2)

odd_cnt = 2
even_cnt = 2
query = [[0]*N for _ in range(N-1)]
for i in range(N-1):
    for j in range(i+1, N):
        if i%2==j%2:
            if i%2==1:
                query[i][j] += odd_cnt
                odd_cnt += 1
            else:
                query[i][j] += even_cnt
                even_cnt += 1
        else:
            query[i][j] = 1

for i in range(N-1):
    print(*[x for x in  query[i] if x!=0])

Submission status: Wrong Answer

Solution code:
N = int(input())

for i in range(N-1):
    ans_i = [i+1]*(N-i-1)
    print(*ans_i)

Submission status: Wrong Answer

Solution code:
N = int(input())
color = (N+1)//2
for j in range(N-1):
  print(*[(i//2+j)%color+1 for i in range(N-1-j)])

Submission status: Wrong Answer

Solution code:
n=int(input())
for i in range(n-1):
  ans=[]
  for j in range(n-1-i):
    if (j)%2==0:
      ans.append('1')
    else:
      ans.append('2')
  print(' '.join(ans))

Submission status: Wrong Answer

Solution code:
def dfs(n,color,l,r):
  if n==2:
    ans[l][r]=color
    return color
  if n%2==1:
    if n==3:
      for i in range(l,r):
        ans[i][r]=evens+1
    else:
      for i in range(l,r):
        if i==n-1 or i==(n-1)//2:
          ans[i][r]=evens
        else:
          ans[i][r]=evens+1
    dfs(n-1,color,l,r-1)
  else:
    for i in range(l,(l+r)//2+1):
      for j in range((l+r)//2+1,r+1):
        ans[i][j]=color
    dfs(n//2,color+1,l,(l+r)//2)
    dfs(n//2,color+1,(l+r)//2+1,r)

n=int(input())
ans=[[0]*(n+1) for _ in range(n+1)]
evens=0
while n!=1:
  if n%2==1:
    n-=1
  else:
    n//=2
    evens+=1
dfs(len(ans)-1,1,1,len(ans)-1)
for i in range(1,len(ans)):
  print(*ans[i][i+1:])

Submission status: Wrong Answer

Solution code:
def dfs(n,color,l,r,cnt):
  if n==2:
    ans[l][r]=color
    return
  if n%2==1:
    for i in range(l,r):
      ans[i][r]=(i-l)%(evens-cnt+1)+(1+cnt)
    dfs(n-1,color,l,r-1,cnt)
  else:
    for i in range(l,(l+r)//2+1):
      for j in range((l+r)//2+1,r+1):
        ans[i][j]=color
    dfs(n//2,color+1,l,(l+r)//2,cnt+1)
    dfs(n//2,color+1,(l+r)//2+1,r,cnt+1)

n=int(input())
ans=[[0]*(n+1) for _ in range(n+1)]
evens=0
while n!=1:
  if n%2==0:
    n//=2
    evens+=1
  elif n%2==1:
    n-=1
dfs(len(ans)-1,1,1,len(ans)-1,0)
for i in range(1,len(ans)):
  print(*ans[i][i+1:])

Submission status: Wrong Answer

Solution code:
n=int(input())
ans=[[0]*(n+1) for _ in range(n+1)]
ans[1][2]=2
for i in range(1,n):
  print(*ans[i][i+1:])

Submission status: Wrong Answer

Solution code:
n=int(input())
print(2)

Submission status: Wrong Answer

Solution code:
def dfs(n,color,l,r):
  if n==2:
    ans[l][r]=color
    return
  if n%2==1:
    for i in range(l,r):
      ans[i][r]=color
    dfs(n-1,color+1,l,r-1)
  else:
    for i in range(l,(l+r)//2+1):
      for j in range((l+r)//2+1,r+1):
        ans[i][j]=color
    dfs(n//2,color+1,l,(l+r)//2)
    dfs(n//2,color+1,(l+r)//2+1,r)

n=int(input())
ans=[[0]*(n+1) for _ in range(n+1)]
dfs(n,1,1,n)
for i in range(1,n):
  print(*ans[i][i+1:])

Submission status: Wrong Answer

Solution code:
n=int(input())
ans=[[0]*(n+1) for _ in range(n+1)]
color=1
while n>=2:
  if n%2==0:
    for i in range(1,n//2+1):
      for j in range(n//2+1,n+1):
        ans[i][j]=color
    color+=1
    n//=2
  elif n%2==1:
    for i in range(1,n):
      ans[i][n]=color
    color+=1
    n-=1
for i in range(1,len(ans)):
  print(*ans[i][i+1:])

Submission status: Wrong Answer

Solution code:
def examA():
    N = DI()/dec(7)
    ans = N
    print(N)
    return

def examB():
    ans = 0
    print(ans)
    return

def examC():
    ans = 0
    print(ans)
    return

def examD():
    N = I()
    n = (N-1).bit_length()
    V = [[-1]*(1<<n) for i in range(1<<n)]
    #print(V)
    for i in range(n):
        b1 = 1 << i
        b2 = 1 << (i + 1)
        for j in range(i+1):
            for k in range(1<<(n-i)):
                for l in range(1<<(n-i)):
                    #print(i,j,k,l,j+k*b2,j+b1+l*b2)
                    if j+k*b2>=N or j+b1+l*b2>=N:
                        continue
                    u,v = sorted([j+k*b2,j+b1+l*b2])
                    #print(u,v)
                    V[u][v-1] = i+1
    ans = [[]for _ in range(N-1)]
    for i in range(N-1):
        for v in V[i]:
            if v>=0:
                ans[i].append(v)
    for v in ans:
        print(" ".join(map(str,v)))
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

def test():
    i = I()
    li = LI()
    lsi = LSI()
    si = LS()
    print(i)
    print(li)
    print(lsi)
    print(si)
    return

from decimal import getcontext,Decimal as dec
import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(input())
def LI(): return list(map(int,sys.stdin.readline().split()))
def DI(): return dec(input())
def LDI(): return list(map(dec,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = dec("0.000000000001")
alphabet = [chr(ord('a') + i) for i in range(26)]
alphabet_convert = {chr(ord('a') + i): i for i in range(26)}

getcontext().prec = 28

sys.setrecursionlimit(10**7)

if __name__ == '__main__':
    examD()

"""
142
12 9 1445 0 1
asd dfg hj o o
aidn
"""

Submission status: Wrong Answer

Solution code:
#Classified
#problem 4
N=int(input())
for i in range(N-1,0,-1):
    A=[N-i for i_ in range(i)]
    print(*A)

Submission status: Wrong Answer

Solution code:
n=int(input())
while n:n-=1;print(*[((x:=n^i)&-x).bit_length()for i in range(n)])

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque
#deque(l), pop(), append(x), popleft(), appendleft(x)
##listでqueの代用をするとO(N)の計算量がかかってしまうので注意
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
#import fractions#古いatcoderコンテストの場合GCDなどはここからimportする
from functools import lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率

def input(): return sys.stdin.readline()[:-1]
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え

    N = int(input())
    #N, K = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列
    cur=1
    for i in range(N-1,0,-1):
        ans=[cur]*i
        print(*ans)
        cur+=1





if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())

lst = [['0' for j in range(n)] for i in range(n)]

for i in range(n-1):
    lst[i][i+1] = '1'

for i in range(n-1):
    num = i+3
    while num <= n-1:
        lst[i][num] = '1'
        num += 2
    level = str(2 + i//2)
    num = i+2
    while num <= n-1:
        lst[i][num] = level
        num += 2

row = 0
idx = 1
while idx < n:
    print(*lst[row][idx:])
    row += 1
    idx += 1

Submission status: Wrong Answer

Solution code:

N = int(input())

for i in range(1, N):
    res = []
    for j in range(i + 1, N + 1):
        if i % 2 == j % 2:
            res.append(2)
        else:
            res.append(1)
    print(*res, sep=" ")

Submission status: Wrong Answer

Solution code:
n = int(input())
for i in range(n-1):
    ans = [i+1]*(n-i-1)
    print(*ans)

Submission status: Wrong Answer

Solution code:
N = int(input())

for i in range(1, N):
    print(' '.join(str(i) * (N - i)))

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

N = int(input())
ans = 0
ans = [[0] * (N+1) for _ in range(N+1)]
depth = 1

def dfs(l, r, d):
    global depth
    if l == r:
        return
    depth = max(depth, d)
    m = (l + r) // 2
    for i in range(l, m+1):
        for j in range(m, r+1):
            ans[i][j] = ans[i][j] = d
    dfs(l, m, d+1)
    dfs(m+1, r, d+1)

dfs(1, N, 1)
print(depth)
for i in range(1, N):
    print(*ans[i][i+1:])

Submission status: Wrong Answer

Solution code:
n = int(input())

for i in range(1, n):
    print(*[i] * (n - i))

Submission status: Wrong Answer

Solution code:
n = int(input())

for i in range(n - 1, 0, -1):
    print(*[1] * i)

Submission status: Wrong Answer

Solution code:
n = int(input())
ans = [[-1] * (n - i - 1) for i in range(n - 1)]
s = [(0, n)]
t = 1
while s:
    p, q = s.pop()
    if p + 1 == q:
        continue
    m = (q - p) // 2 + p
    for i in range(p, m):
        for j in range(m, q):
            ans[i][j - i - 1] = t
    t += 1
    s.append((p, m))
    s.append((m, q))
for row in ans:
    print(' '.join(map(str, row)))

Submission status: Wrong Answer

Solution code:
N = int(input())
for i in range(N - 2):
  for j in range(N - i - 2):
    print(2, end = " ")
  print(2)
print(1)

Submission status: Wrong Answer

Solution code:
n = int(input())
for i in range(1, n):
  print(*[i]*(n-i))

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
N = int(input())
res = [[0] * x for x in range(N - 1, 0, -1)]
for x in range(N - 1):
  for y in range(N - 1 - x):
    b = 0
    for k in range(10):
      if y + 1 < pow(2, k): break
      b = k + 1
    res[x][y] = b
for r in res: print(*r)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
N = int(input())
res = [[0] * x for x in range(N - 1, 0, -1)]
for x in range(N - 1):
  for y in range(N - 1 - x):
    b = (y + 1).bit_length()
    res[x][y] = b
for r in res: print(*r)

Submission status: Wrong Answer

Solution code:
n = int(input())
ans = 0
while(n >1):
  n /= 2
  ans+=1
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
if n%2:
  m = n+1
else:
  m = n
ans = [[] for i in range(m-1)]
for i in range(m-1):
  for j in range(m-1-i):
    if j%2 == 0:
      ans[i].append(1)
    else:
      ans[i].append(min(i+2,m-i-j))
if n%2:
  del ans[0]
for arr in ans:
  print(*arr,sep=" ")

Submission status: Wrong Answer

Solution code:
n = int(input())
if n%2:
  m = n+1
else:
  m = n
ans = [[] for i in range(m-1)]
for i in range(m-1):
  for j in range(m-1-i):
    if j%2 == 0:
      ans[i].append(1)
    else:
      ans[i].append(min(i+2,m-i-j))
if n%2:
  del ans[0]
for arr in ans:
  print(*arr,sep="")

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    n=int(input())
    col=[[None]*n for _ in range(n)]

    def coloring(A,c): # A: sorted list
        n=len(A)
        # terminate
        if(n==2):
            col[A[0]][A[1]]=c
            return

        if(n&1): # 奇数のとき -> 末尾から全てに辺を伸ばして1つ減らす
            v=A[-1]
            for i in range(n-1):
                u=A[i]
                col[u][v]=c
            coloring(A[:n-1],c+1)

        else: # 偶数のとき: 距離が奇数のもの全てに辺を張り、半分ずつを渡す
            for i in range(n):
                for j in range(i+1,n):
                    if((j-i)&1):
                        col[A[i]][A[j]]=c
            A1=[a for i,a in enumerate(A) if(i&1)]
            A2=[a for i,a in enumerate(A) if(not i&1)]
            coloring(A1,c+1)
            coloring(A2,c+1)

    coloring(list(range(n)),1)
    for i in range(n-1):
        print(*col[i][i+1:])
resolve()

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    n=int(input())
    col=[[None]*n for _ in range(n)]

    def coloring(A,c): # A: sorted list
        n=len(A)
        # terminate
        if(n==2):
            col[A[0]][A[1]]=c
            return

        if(n&1): # 奇数のとき -> 末尾から全てに辺を伸ばして1つ減らす
            v=A[-1]
            for i in range(n-1):
                u=A[i]
                col[u][v]=c
            coloring(A[:n-1],c+1)

        else: # 偶数のとき: 距離が奇数のもの全てに辺を張り、半分ずつを渡す
            for u in range(n):
                for v in range(u+1,n):
                    if((v-u)&1):
                        col[u][v]=c
            A1=[a for i,a in enumerate(A) if(i&1)]
            A2=[a for i,a in enumerate(A) if(not i&1)]
            coloring(A1,c+1)
            coloring(A2,c+1)

    coloring(list(range(n)),1)
    for i in range(n-1):
        print(*col[i][i+1:])
resolve()

Submission status: Wrong Answer

Solution code:
N = int(input())

vec = [[0] * N for _ in range(N)]
M = 1
for i in range(1, N // 2 + 1) :
    visited = [False] * N
    if i % 3 == 0 and N % 2 == 0 :
        color = vec[0][i // 3]
    else :
        color = M
        
    for j in range(N) :
        if visited[j] : 
            continue
        parity = 0
        visited[j] = True
        while not visited[(j + i) % N] :
            vec[j][(j + i) % N] = vec[(j + i) % N][j] = color
            visited[(j + i) % N] = True
            parity ^= 1
            j = (j + i) % N
        
        if parity == 1 :
            vec[j][(j + i) % N] = vec[(j + i) % N][j] = color
        
    if color == M :
        M += 1
        
for i in range(N) :
    for j in range(i + 1, N) :
        if vec[i][j] == 0 :
            vec[i][j] = vec[j][i] = M
            
for i in range(N) :
    print(*vec[i][i+1:])

Submission status: Wrong Answer

Solution code:
N = int(input())

vec = [[0] * N for _ in range(N)]
M = 1
for i in range(1, N // 2 + 1) :
    visited = [False] * N
    if i % 3 == 0 :
        color = vec[0][i // 3]
    else :
        color = M
        
    for j in range(N) :
        if visited[j] : 
            continue
        parity = 0
        visited[j] = True
        while not visited[(j + i) % N] :
            vec[j][(j + i) % N] = vec[(j + i) % N][j] = color
            visited[(j + i) % N] = True
            parity ^= 1
            j = (j + i) % N
        
        if parity == 1 :
            vec[j][(j + i) % N] = vec[(j + i) % N][j] = color
        
    if color == M :
        M += 1
        
for i in range(N) :
    for j in range(i + 1, N) :
        if vec[i][j] == 0 :
            vec[i][j] = vec[j][i] = M
            
for i in range(N) :
    print(*vec[i][i+1:])

Submission status: Wrong Answer

Solution code:
N = int(input())

vec = [[2 if N == 3 else 3] * N for _ in range(N)]

for i in range(N) :
  for j in range(i + 1, N) :
    if i == 0 and j == N - 1 and N % 2 == 1 :
      continue
    if (j - i) % 2 == 1 :
      vec[i][j] = vec[j][i] = 1
    else :
      vec[i][j] = vec[j][i] = 2

for i in range(N) :
  print(*vec[i][i+1:])

Submission status: Wrong Answer

Solution code:
N = int(input())

n = 0
while True:
    if 2**n >= N:
        break
    n += 1
print(n)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from datetime import date, timedelta
from heapq import*
import math
from collections import defaultdict, Counter, deque
import sys
from bisect import *
import itertools
import copy
sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7

def main():
    n = int(input())
    if n % 2 == 0:
        for i in range(n - 1):
            l = []
            if i == 0:
                l = [1] * (n - 2) + [2]
                print(*l)
            else:
                if i % 2 == 1:
                    l = [2] + [1] * (n - i - 2)
                else:
                    l = [1]*(n - i - 1)
                print(*l)
    else:
        pass

                    


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())
if n == 3:
  print(1,2)
  print(1)
else:
  pass

Submission status: Wrong Answer

Solution code:
n = int(input())
if n == 3:
  print(1,1)
  print(1)
else:
  pass

Submission status: Wrong Answer

Solution code:
N = int(input())
for i in range(1,N):
    A = [i for _ in range(i+1,N+1)]
    print(*A)

Submission status: Wrong Answer

Solution code:
n = int(input())
lg = 0
while n>>lg >=1:
    lg += 1

a = [[0 for _ in range(n)] for __ in range(n)]
for i in range(n):
    for j in range(i+1,n):
        for k in range(lg):
            if (i>>k)&1!=(j>>k)&1:
                a[i][j] = k+1
                break

for i in range(1,n):
    for j in range(i,n):
        print(a[i][j], end = " ")
    print()

Submission status: Wrong Answer

Solution code:
N = int(input())
for i in range(N-1):
    print(*[(i^j).bit_length() for j in range(i, N)])

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N = INT()

for i in range(N-1):
    ans = [i+1] * (N-i-1)
    print(*ans)

Submission status: Wrong Answer

Solution code:
s="1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 5 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 6 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 5 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 7 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 5 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 6 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 5 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 8 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 5 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 6 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 5 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 7 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 5 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 6 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 5 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 9 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 5 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 6 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 5 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 7 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 5 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 6 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 5 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 8 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 5 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 6 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 5 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 7 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 5 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 6 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 5 1"
i=int(input())*2-3
for j in range(i, 0, -2):
    print(s[:j])

Submission status: Wrong Answer

Solution code:
N=int(input());exec("N-=1;print(*[len(bin(i+1))-2for i in range(N)]);"*N)

Submission status: Wrong Answer

Solution code:
N=int(input());exec("N-=1;print(*[len(bin(i))-2for i in range(N)]);"*N)

Submission status: Wrong Answer

Solution code:
N,i=int(input()),0;exec("i+=1;print(*[9-format(i,'09b').rfind('1')]*(N-i));"*N)

Submission status: Wrong Answer

Solution code:
N=int(input())
for i in range(N):
    print(*[len(bin(i+1))-2]*(N-i-1))

Submission status: Wrong Answer

Solution code:
N=int(input())
for i in range(N):
    print(*[len(bin(i+1))-2]*(N-i))

Submission status: Wrong Answer

Solution code:
import sys
from pprint import pprint

def solve(n):
    for i in range(1, n):
         edges = []
         for j in range(i+1, n+1):
             xor = i ^ j
             # print(i, j, xor)
             for k, v in {256:9,128:8,64:7,32:6,16:5,8:4,4:3,2:2,1:1}.items():
                 if k <= xor:
                     edges.append(v)
                     break
         print(" ".join(map(str,edges)))

if __name__ == '__main__':
    n = int(sys.stdin.readline().strip())
    solve(n)

Submission status: Wrong Answer

Solution code:
import sys
from pprint import pprint

def solve(n):
    for i in range(1, n):
         edges = []
         for j in range(i+1, n+1):
             xor = i ^ j
             # print(i, j, xor)
             for k in [256,128,64,32,16,8,4,2,1]:
                 if k <= xor:
                     edges.append(k)
                     break
         print(" ".join(map(str,edges)))

if __name__ == '__main__':
    n = int(sys.stdin.readline().strip())
    solve(n)

Submission status: Wrong Answer

Solution code:
#### import ####
import sys
import math
from collections import defaultdict

#### 設定 ####
sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

#### 定数 ####
mod = 10**9 + 7

#### 読み込み ####
def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
    read_all = [tuple(map(int, input().split())) for _ in range(N)]
    return map(list,zip(*read_all))

#################

N = I()
n = len(format(N,'b'))

for i in range(N-1):
    i2 = format(i,'b').zfill(n)
    ans = []
    for j in range(i+1,N):
        j2 = format(j,'b').zfill(n)
        for k in range(n):
            if i2[k] != j2[k]:
                ans.append(k+1)
                break
    print(*ans)

Submission status: Wrong Answer

Solution code:
r=range(int(input()))
for _ in r:print(*[bin(j+1)[::-1].find('1')+1for j in r])

Submission status: Wrong Answer

Solution code:
n=int(input())
while n:print(*[bin(j+1)[::-1].index('1')+1for j in range(n)]);n-=1

Submission status: Wrong Answer

Solution code:

def even(N):
    for i in range(1, N):
        print(*[1 if (i + j) % 2 == 1 else 2 for j in range(i+1,N+1)])

def odd(N):
    l = [1 if (1 + j) % 2 == 1 else 2 for j in range(2, N-1)]
    l.append(3 if N > 3 else 2)
    print(*l)

    for i in range(2, N+1):
        print(*[1 if (i + j) % 2 == 1 else 2 for j in range(i+1,N+1)])


def solve(N):
    if N % 2 == 0:
        even(N)
    else:
        odd(N)
N = int(input())
solve(N)

Submission status: Wrong Answer

Solution code:
from math import log, floor

N = int(input())

for i in range(N - 1):
    ans = [1 + floor(log(j, 2)) for j in range(1, N - i)]
    print(*ans)

Submission status: Wrong Answer

Solution code:
def main(n):
	for i in range(n-1):
		for j in range(n-i-1):
			if j % 2 == 0:
				print(j//2+1, end= " " if j!= n-i-2 else "\n")
			else:
				if (i+j//2+2) <= n//2:
					temp = i+j//2+2
				else:
					temp = n+1-(i+j//2+2)
				print(temp, end=" " if j!= n-i-2 else "\n")
		
main(int(input()))

Submission status: Wrong Answer

Solution code:
n = int(input())
lv = [[0 for i in range(n)] for j in range(n)]

def dfs(x, cur):
  for nex in range(x+1, n):
    if x==nex or lv[x][nex]!=0:
      continue
    lv[x][nex] = cur
    dfs(nex, -1*cur)

dfs(0, 1)

cnta, cntb = 0, 0
for i in range(n-1):
  for j in range(i+1, n):
    if lv[i][j]==1:
      cnta += 1
    else:
      cntb += 1

for i in range(n-1):
  cur = []
  for j in range(i+1, n):
    if (cnta>cntb and lv[i][j]==1) or (cnta<cntb and lv[i][j]==-1):
      cur.append(1)
    else:
      cur.append(2)
  print(*cur)

Submission status: Wrong Answer

Solution code:
def main(n):
	a = []
	b = []
	for i in range(n//2):
		a += [i+1]
		b = [i+1] + b
	ans = a+b
	for i in range(n-1):
		if i % 2 == 0:
			print(" ".join(map(str, [i//2 + 1]*(n-i-1))))
		else:
			ans = ans[1:-1]
			print(" ".join(map(str,ans)))
		
main(int(input()))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
from itertools import combinations

def solve():
    N = int(input())
    M = 2**(N-1).bit_length()
    E = [[0 for j in range(M+1)] for i in range(M+1)]
    for i,j in combinations(range(1,M+1), r=2):
        if (i-j)%2:
            E[i][j] = 1
        else:
            E[i][j] = min(j-i, i-j+M)//2+1
    
    res = '\n'.join(' '.join(map(str,e[i+2:N+1])) for i, e in enumerate(E[1:N+1]))
    return str(res)

if __name__ == '__main__':
    print(solve())

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
from itertools import combinations

def solve():
    N = int(input())
    M = 2**N.bit_length()

    #(i,j) -> E[i-1][j-2], i < j
    E = [[0 for j in range(M+1)] for i in range(M+1)]
    for i,j in combinations(range(1,M+1), r=2):
        if (i-j)%2:
            E[i][j] = 1
        else:
            E[i][j] = min(j-i, i-j+8)//2+1
    
    res = '\n'.join(' '.join(map(str,e[i+2:N+1])) for i, e in enumerate(E[1:N+1]))
    return str(res)

if __name__ == '__main__':
    print(solve())

Submission status: Wrong Answer

Solution code:
def f_d():
    n = int(input())
    for i in range(n-1):
        print(" ".join([str(i+1)]*(n-i-1)))

if __name__ == "__main__":
    f_d()