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:
import bisect
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

N = int(sys.stdin.readline())

# 全域木をいい感じに作ればよさげ
ans = np.zeros((N, N), dtype=int)
graph = [set(list(range(N))) - {i} for i in range(N)]

level = 1
v = 0
cnt = 0
while cnt < (N - 1) * N // 2:
    vv = v
    s = {v}
    while len(graph[v] - s) >= 1:
        u = (graph[v] - s).pop()
        graph[v].remove(u)
        graph[u].remove(v)
        s.add(u)
        ans[v][u] = level
        v = u
    v = vv
    while len(graph[v] - s) >= 1:
        u = (graph[v] - s).pop()
        graph[v].remove(u)
        graph[u].remove(v)
        s.add(u)
        ans[v][u] = level
        v = u
    cnt += len(s) - 1
    level += 1
    v = np.argmax([len(s) for s in graph])

ans = np.maximum(ans, ans.T)

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

Submission status: Wrong Answer

Solution code:
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n = ni()

p = [[1],[1,2],[1,2,1]]

for i in range(3,253):
    a = p[-1]
    c = [i] + a
    p.append(c)
    d = [i-1] + list(reversed(c))
    p.append(d)

for i in reversed(range(n-1)):
    print(' '.join([str(u) for u in p[i]]))

Submission status: Wrong Answer

Solution code:
import bisect
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

N = int(sys.stdin.readline())

# 全域木をいい感じに作ればよさげ
ans = np.zeros((N, N), dtype=int)
graph = [set(list(range(N))) - {i} for i in range(N)]

level = 1
v = 0
cnt = 0
while cnt < (N - 1) * N // 2:
    vv = v
    s = {v}
    while len(graph[v] - s) >= 1:
        u = (graph[v] - s).pop()
        graph[v].remove(u)
        graph[u].remove(v)
        s.add(u)
        ans[v][u] = level
        v = u
    v = vv
    while len(graph[v] - s) >= 1:
        u = (graph[v] - s).pop()
        graph[v].remove(u)
        graph[u].remove(v)
        s.add(u)
        ans[v][u] = level
        v = u
    cnt += len(s) - 1
    level += 1
    v = np.argmax([len(s) for s in graph])

ans = np.maximum(ans, ans.T)

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

Submission status: Wrong Answer

Solution code:
from collections import deque
N=int(input())
if N%2==1:
    a=[[0 for j in range(N-i-1)] for i in range(N-1)]
    K=N//2
    #i->j(i<j)
    #a[i-1][j-i-1]
    for k in range(1,K+1):
        x=1
        for i in range(N-1):
            y,x=x,(x+k)%N
            if x==0:
                x=N
            if y==0:
                y=N
            p,q=min(x,y),max(x,y)
            #print(k,i,p,q,x,y)
            a[p-1][q-p-1]=k

    for i in range(N-1):
        for j in range(N-i-1):
            if a[i][j]==0:
                a[i][j]=K+1
    for i in range(N-1):
        print(*a[i])
else:
    K=N//2
    q=deque([i for i in range(1,N+1)])
    X=[]
    X.append(q.popleft())
    X.append(q.popleft())
    index=0
    while(len(q)>0):
        if index%2==0:
            X.append(q.pop())
        else:
            X.append(q.popleft())
        index+=1
    #print(X)
    a=[[0 for j in range(N-i-1)] for i in range(N-1)]
    for k in range(1,K+1):
        for i in range(N-1):
            x,y=(X[i]+k)%N,(X[i+1]+k)%N
            if x==0:
                x=N
            if y==0:
                y=N
            p,q=min(x,y),max(x,y)
            a[p-1][q-p-1]=k
    for i in range(N-1):
        print(*a[i])

Submission status: Wrong Answer

Solution code:
from math import ceil
N = int(input())

level1 = N%2
level2 = ceil(N//2)%2

for i in range(N-1):
    if i == N-1 and level1==1 and N > 3:
        print(3)
    elif i == N-2 and level2==1 and N > 4:
        ans = [1, 3]
        print(*ans)
    res = [k%2+1 for k in range(0, N-i-1)]
    print(*res)

Submission status: Wrong Answer

Solution code:
N=int(input())

if N!=3 and N!=2: 
	for i in range(N-1):
		for j in range(i,N-1):
			if N%2!=0:
				if i==0 and j==N-2:
					print(2,end='')
				else:print(1,end=' ')
			else: print(1,end=' ')
		print()
else:
	if N==2:
		print(1)
	if N==3:
		print(1,2)
		print(1)

Submission status: Wrong Answer

Solution code:
from collections import deque
N=int(input())
if N==2:
    print(1)
    exit()
elif N==3:
    print(1,2)
    print(1)
    exit()
elif N==4:
    print(2,1,1)
    print(1,2)
    print(2)
    exit()
a=[[0 for j in range(N-i-1)] for i in range(N-1)]
#i->j(i<j)
#a[i-1][j-i-1]
for i in range(1,N+1):
    for j in range(i+1,N+1):
        if (i+j)%2==1:
            a[i-1][j-i-1]=1
        elif (i*j)%2==1:
            a[i-1][j-i-1]=2
        else:
            a[i-1][j-i-1]=3
for i in range(N-1):
    print(*a[i])

Submission status: Wrong Answer

Solution code:
N = int(input())

if N%2==0:
        ans = []

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


for a in ans:
        print(*a)

Submission status: Wrong Answer

Solution code:
n=int(input())
l=[1, 2, 1, 3, 2, 1, 4, 3, 2, 1, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 14, 13, 12, 11, 10, 9]
for i in range(n):
    print(*l[:n-i-1])

Submission status: Wrong Answer

Solution code:
import math
N = int(input())

for i in range(N - 1):
    for j in range(N - i - 1):
        print((j % math.ceil(N / 2)) + 1, end=' ')
    print()

Submission status: Wrong Answer

Solution code:
n = int(input())
for i in range(n - 1):
  for j in range(n - 1 - i):
    if j == n - 2 and n % 2 == 0:
      print(1, ' ', end='')
    else:
      print(j + 1, ' ', end='')
  print('')

Submission status: Wrong Answer

Solution code:
n = int(input())

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

e = n*(n-1)//2

if n>=e-n:
  for i in range(n-1):
    cur = []
    for j in range(i+1, n):
      if i==0 and j==n-1:
        cur.append(1)
      elif j==i+1:
        cur.append(1)
      else:
        cur.append(2)
    print(*cur)
else:
  for i in range(n-1):
    cur = []
    for j in range(i+1, n):
      if i==0 and j==n-1:
        cur.append(2)
      elif j==i+1:
        cur.append(2)
      else:
        cur.append(1)
    print(*cur)

Submission status: Wrong Answer

Solution code:
N = int(input())

if N%2==0:
        ans = []

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

print(ans)

for a in ans:
        print(*a)

Submission status: Wrong Answer

Solution code:
from math import ceil
N = int(input())

level1 = N%2
level2 = ceil(N//2)%2

for i in range(N-1):
    if i == N-1 and level1==1 and N > 3:
        print(3)
    elif i == N-2 and level2==1 and N > 4:
        ans = [1, 3]
        print(*ans)
    res = [k%2+1 for k in range(i, N)]
    print(*res)

Submission status: Wrong Answer

Solution code:
N=int(input())

if N!=3 and N!=2: 
	for i in range(N-1):
		for j in range(i,N-1):
			if N%2!=0:
				print(2 if i==j else 1,end=' ')
			else: print(1,end=' ')
		print()
else:
	if N==2:
		print(1)
	if N==3:
		print(1,2)
		print(1)

Submission status: Wrong Answer

Solution code:
import sys, math
from collections import deque

readline = sys.stdin.readline

N = int(readline())

for i in range(N - 1, 0, -1):
    for j in range(i):
        sys.stdout.write(str(j + 1) + ' ')
    print('')

Submission status: Wrong Answer

Solution code:
n=int(input())
l=[1, 2, 1, 3, 1, 2, 4, 1, 5, 1, 2, 3, 6, 1, 7, 1, 2, 4, 8, 1, 3, 9, 1, 2, 5, 10, 1, 11, 1, 2, 3, 4, 6, 12, 1, 13, 1, 2, 7, 14, 1, 3, 5, 15, 1, 2, 4, 8, 16, 1, 17, 1, 2, 3, 6, 9, 18, 1, 19, 1, 2, 4, 5, 10, 20, 1, 3, 7, 21, 1, 2, 11, 22, 1, 23, 1, 2, 3, 4, 6, 8, 12, 24, 1, 5, 25, 1, 2, 13, 26, 1, 3, 9, 27, 1, 2, 4, 7, 14, 28, 1, 29, 1, 2, 3, 5, 6, 10, 15, 30, 1, 31, 1, 2, 4, 8, 16, 32, 1, 3, 11, 33, 1, 2, 17, 34, 1, 5, 7, 35, 1, 2, 3, 4, 6, 9, 12, 18, 36, 1, 37, 1, 2, 19, 38, 1, 3, 13, 39, 1, 2, 4, 5, 8, 10, 20, 40, 1, 41, 1, 2, 3, 6, 7, 14, 21, 42, 1, 43, 1, 2, 4, 11, 22, 44, 1, 3, 5, 9, 15, 45, 1, 2, 23, 46, 1, 47, 1, 2, 3, 4, 6, 8, 12, 16, 24, 48, 1, 7, 49, 1, 2, 5, 10, 25, 50, 1, 3, 17, 51, 1, 2, 4, 13, 26, 52, 1, 53, 1, 2, 3, 6, 9, 18, 27, 54, 1, 5, 11, 55, 1, 2, 4, 7, 8, 14, 28, 56, 1, 3, 19, 57, 1, 2, 29, 58, 1, 59, 1, 2, 3, 4, 5, 6, 10, 12, 15, 20, 30, 60, 1, 61, 1, 2, 31, 62, 1, 3, 7, 9, 21, 63, 1, 2, 4, 8, 16, 32, 64, 1, 5, 13, 65, 1, 2, 3, 6, 11, 22, 33, 66, 1, 67, 1, 2, 4, 17, 34, 68, 1, 3, 23, 69, 1, 2, 5, 7, 10, 14, 35, 70, 1, 71, 1, 2, 3, 4, 6, 8, 9, 12, 18, 24, 36, 72, 1, 73, 1, 2, 37, 74, 1, 3, 5, 15, 25, 75, 1, 2, 4, 19, 38, 76, 1, 7, 11, 77, 1, 2, 3, 6, 13, 26, 39, 78, 1, 79, 1, 2, 4, 5, 8, 10, 16, 20, 40, 80, 1, 3, 9, 27, 81, 1, 2, 41, 82, 1, 83, 1, 2, 3, 4, 6, 7, 12, 14, 21, 28, 42, 84, 1, 5, 17, 85, 1, 2, 43, 86, 1, 3, 29, 87, 1, 2, 4, 8, 11, 22, 44, 88, 1, 89, 1, 2, 3, 5, 6, 9, 10, 15, 18, 30, 45, 90, 1, 7, 13, 91, 1, 2, 4, 23, 46, 92, 1, 3, 31, 93, 1, 2, 47, 94, 1, 5, 19, 95, 1, 2, 3, 4, 6, 8, 12, 16, 24, 32, 48, 96, 1, 97, 1, 2, 7, 14, 49, 98, 1, 3, 9, 11, 33, 99, 1, 2, 4, 5, 10, 20, 25, 50, 100, 1, 101, 1, 2, 3, 6, 17, 34, 51, 102, 1, 103, 1, 2, 4, 8, 13, 26, 52, 104, 1, 3, 5, 7, 15, 21, 35, 105, 1, 2, 53, 106, 1, 107, 1, 2, 3, 4, 6, 9, 12, 18, 27, 36, 54, 108, 1, 109, 1, 2, 5, 10, 11, 22, 55, 110, 1, 3, 37, 111, 1, 2, 4, 7, 8, 14, 16, 28]
for i in range(n):
    print(*l[:n-i-1])

Submission status: Wrong Answer

Solution code:
N=int(input())
def tigai(a,b):
  for i in range(10):
    x = (a>>i)%2
    y = (b>>i)%2
    if x!=y:
      return(i+1)

for i in range(N):
  k = N-i
  print(*[tigai(k,j) for j in range(1,k)])

Submission status: Wrong Answer

Solution code:
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n = ni()

p = [[1],[1,2]]

for i in range(1,251):
    a = p[-1]
    c = [i] + list(reversed(a))
    p.append(c)
    d = [i+1] + c
    p.append(d)

for i in reversed(range(n-1)):
    print(' '.join([str(u) for u in p[i]]))

Submission status: Wrong Answer

Solution code:
import sys, math
from collections import deque

readline = sys.stdin.readline

N = int(readline())

for i in range(1, N):
    for j in range(i):
        sys.stdout.write(str(j + 1) + ' ')
    print('')

Submission status: Wrong Answer

Solution code:
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    m,d = LI()
    ans = 0
    for i in range(1,m+1):
        for j in range(1,d+1):
            d1 = j%10
            d2 = j//10
            if d1 >= 2 and d2 >= 2 and d1*d2 == i:
                ans += 1
    print(ans)
    return

#B
def B():
    def add(i):
        while i <= m:
            bit[i] += 1
            i += i&-i

    def sum(i):
        res = 0
        while i > 0:
            res += bit[i]
            i -= i&-i
        return res

    n,k = LI()
    m = 2000
    a = LI()
    bit = [0]*(m+1)
    ans = 0
    for i in range(n):
        ans += (i-sum(a[i]))*k
        add(a[i])
    inv = pow(2,mod-2,mod)
    for i in range(n):
        ans += sum(a[i]-1)*k*(k-1)*inv%mod
    print(ans%mod)
    return

#C
def C():
    n = I()
    s = S()
    if "W" in (s[0],s[-1]):
        print(0)
        return

    return

#D
def D():
    n = I()
    k = n//2+n%2
    v = [[] for i in range(n-1)]
    for i in range(n-1):
        for j in range(n-i-1):
            v[i].append((i+j)%k+1)
    for i in v:
        print(*i)
    return

#E
def E():

    return

#F
def F():

    return

#Solve
if __name__ == "__main__":
    D()

Submission status: Wrong Answer

Solution code:
N = int(input())

if N%2==0:
        ans = []

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


for a in ans:
        print(*a)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [[1 for i in range(N-1)] for i in range(N-1)]
count = 2
n = N
m = 1
while(n >= 3):
    for j in range(n//2):
        for i in range(n-1-j):
            for k in range(m):
                A[i+k*n][j+k*n] = count
                count += 1
    m = m * 2
    n = n // 2
for i in range(N):
    for j in range(N-1-i):
        print(A[i][j],end = " ")
    print("")

Submission status: Wrong Answer

Solution code:
N = int(input())

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

mx = 0
for i in range(N-1):
    for j in range(i+1,N):
        k = j-i
        a = 1
        while k&1==0:
            a += 1
            k >>= 1
        ans[i][j] = a
        mx = max(mx, ans[i][j])

if N%2 and N>3:
    ans[0][-1] = mx + 1

for i,row in enumerate(ans[:-1]):
    print(*(row[i+1:]))

Submission status: Wrong Answer

Solution code:
N=input()
for i in range(1,N):
	print " ".join([str(i)]*(N-i))

Submission status: Wrong Answer

Solution code:
n=int(input())
l=[1, 2, 1, 3, 1, 2, 4, 1, 5, 1, 2, 3, 6, 1, 7, 1, 2, 4, 8, 1, 3, 9, 1, 2, 5, 10, 1, 11, 1, 2, 3, 4, 6, 12, 1, 13, 1, 2, 7, 14, 1, 3, 5, 15, 1, 2, 4, 8, 16, 1, 17, 1, 2, 3, 6, 9, 18, 1, 19, 1, 2, 4, 5, 10, 20, 1, 3, 7, 21, 1, 2, 11, 22, 1, 23, 1, 2, 3, 4, 6, 8, 12, 24, 1, 5, 25, 1, 2, 13, 26, 1, 3, 9, 27, 1, 2, 4, 7, 14, 28, 1, 29]
for i in range(n):
    print(*l[:n-i-1])

Submission status: Wrong Answer

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  I()
  print('1 2 2 3')
  print('1 2 1')
  print('1 2')
  print('2')

# main()
print(main())

Submission status: Wrong Answer

Solution code:
n = int(input())

for i in range(1, n):
    ans = []
    for j in range(n-i):
        # print(i, j)
        if j % 2 == 0:
            ans.append(1)
        else:
            ans.append(2 + (i-1)//2)
    print(' '.join([str(ansi) for ansi in ans]))

Submission status: Wrong Answer

Solution code:
n = int(input())

p = [-1]*501

q = 1

for i in range(1,n):
    for j in range(i+1,n+1):
        if p[j-i] == -1:
            if j == n:
                print(q)
            else:
                print(q,end = ' ')
            ind = j-i
            while ind <= len(p)-1:
                p[ind] = q
                ind += q*2
            q += 1
        else:
            if j==n:
                print(p[j-i])
            else:
                print(p[j-i],end = ' ')

Submission status: Wrong Answer

Solution code:
N = int(input())

ans = []
for i in range(N-1):
    ans.append([0] * (N - i - 1))

flag = 0
for step in range(1, N // 2 + 1):
    i = 0
    i_start = 0
    counter = 0
    visited = [0] * N
    while True:
        if visited[i] == 1:
            break
        if i + step <= N - 1:
            ans[i][step - 1] = step
            i_new = i + step
        else:
            i_new = (i + step) % N
            ans[i_new][i - i_new - 1] = step
        counter += 1
        if i_new == i_start:
            if counter % 2 == 1:
                ans[i_new][i - i_new - 1] = 0
                if step == N // 2:
                    flag = 1
            i_start += 1
            i = i_start
            counter = 0
        else:
            visited[i] = 1
            i = i_new

for i in range(N - 1):
    for j in range(N - i - 1):
        if ans[i][j] == 0:
            ans[i][j] = N // 2 if flag == 0 else N // 2 + 1

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

Submission status: Wrong Answer

Solution code:
import math
n=int(input())
s=1
i=0
while 1:
    i+=1
    s+=i
    if s>=n:break
print(i)

Submission status: Wrong Answer

Solution code:
N=int(input())
for i in range(N-1):
    x=i+1 if i<N//2 else N-i-1
    print(*[x]*(N-i-1))

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())

if n == 3:
    print("1 2")
    print(1)
else:
    edges = [set() for i in range(n)]

    ans = [[0 for i in range(n)] for j in range(n)]
    checked = set()
    for i in range(n):
        if i+1 == n:
            temp = 0
        else:
            temp = i+1
        checked.add(str(i)+","+str(temp))
        checked.add(str(temp) + "," + str(i))
    for i in range(n-1):
        ans[i][i+1] = 1
    ans[0][-1] = 1

    for i in range(n):
        edges[i].add(1)
    for i in range(n):
        for j in range(i+1,n):
            if str(i)+","+str(j) not in checked:
                flag = False
                e = 0
                for f in edges[i]:
                    if f not in edges[j]:
                        e = f
                        flag = True
                        break
                if flag:
                    edges[j].add(e)
                    ans[i][j] = e
                else:
                    cle = max(edges[i])+1
                    # while True:
                    #     if cle not in edges[j]:
                    #         break
                    #     else:
                    #         cle += 1
                    edges[j].add(cle)
                    ans[i][j] = cle
                checked.add(str(i)+","+str(j))
                checked.add(str(j)+","+str(i))
    #     print(edges)
    #
    # print(np.array(ans))

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

Submission status: Wrong Answer

Solution code:
n = int(input())

p = [-1]*501

q = 1

for i in range(1,n):
    for j in range(i+1,n+1):
        if p[j-i] == -1:
            if j == n:
                print(q)
            else:
                print(q,end = ' ')
            ind = q
            while ind <= len(p)-1:
                p[ind] = q
                ind += q*2
            q += 1
        else:
            if j==n:
                print(p[j-i])
            else:
                print(p[j-i],end = ' ')

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [[1 for i in range(N-1)] for i in range(N-1)]
count = 2
n = N
m = 1
while(n >= 3):
    for j in range(n//2):
        for i in range(n-1-j):
            for k in range(m):
                A[i+k*n][j+k*n] = count
    count += 1
    m = m * 2
    n = n // 2
for i in range(N):
    for j in range(N-1-i):
        print(A[i][j],end = " ")
    print("")

Submission status: Wrong Answer

Solution code:
N = int(input())
def calc(i, j):
    if j-i == 2 or j-i == 6 or  (j-i == 1 and i % 2): return 1
    if (j-i==1 and j % 2) or (j-i==3 and i % 2) or (j-i==5 and j % 2) or (j-i==7 and i % 2): return 2
    k = (j-1)//2 - (i-1)//2 + 1
    return k if k < 4 else k-1

for i in range(1, N+1):
    print(*[calc(i, j) for j in range(i+1, N+1)])

Submission status: Wrong Answer

Solution code:
from collections import Counter, defaultdict
import sys
sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline
from math import factorial
import heapq, bisect
import math
import itertools


def main():
    num = int(input())
    data = [[0 for i in range(num)] for j in range(num)]

    aaa = num
    honsuu = 0
    while aaa > 0:
        while aaa % 2 == 0:
            aaa //= 2
        honsuu += 1
        aaa -= 1

    for i in range(num):
        now_flg = 1
        for j in range(i + 1, num):
            if data[i][j] != 0:
                continue
            if abs(i - j) % 2 == 1:
                data[i][j] = 1
                data[j][i] = 1
            else:
                now_flg += 1
                data[i][j] = now_flg
                data[j][i] = now_flg

                # print(now_flg, honsuu)
                now_flg %= honsuu
                if now_flg <= 1:
                    now_flg = 2


    for i in range(num - 1):
        data_str = list(map(str, data[i]))
        ans = ' '.join(data_str[i + 1:])
        print(ans)





if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n = ni()

p = [[1],[1,2]]

for i in range(1,251):
    a = p[-1]
    c = [i] + list(reversed(a))
    p.append(c)
    d = [i+2] + c
    p.append(d)

for i in reversed(range(n-1)):
    print(' '.join([str(u) for u in p[i]]))

Submission status: Wrong Answer

Solution code:
N = int(input())
from collections import defaultdict

used = defaultdict(int)
for i in range(1, N + 1):
    if i == N:
        continue
    for j in range(i + 1, N + 1):
        if (j - i) % 2 == 0:
            if j in used:
                tmp = used[j]
                print(tmp + 1, end=" ")
                used[j] = tmp + 1
            else:
                tmp = 2
                used[j] = tmp
                print(tmp, end=" ")
        else:
            print(1, end=" ")
    print()

Submission status: Wrong Answer

Solution code:
N = int(input())

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

mx = 0
for i in range(N-1):
    for j in range(i,N):
        if (j-i)%2:
            ans[i][j] = 1
        elif (j-i)%4:
            ans[i][j] = 2
        else:
            ans[i][j] = 3
        mx = max(mx, ans[i][j])

if N%2 and N>3:
    ans[0][-1] = mx + 1

for i,row in enumerate(ans[:-1]):
    print(*(row[i+1:]))

Submission status: Wrong Answer

Solution code:
import math
n=int(input())
l=[1,2,4,8,16,32,64,128,256,512]
for i in range(len(l)):
  if n>l[i]:
    N=l[i+1]
ans=[['0' for i in range(N)] for j in range(N)]
for i in range(N):
  for j in range(N):
    if i!=j:
      ans[i][j]=str(int(math.log(abs(i-j),2))+1)
for i in range(n-1):
  x=ans[i][1+i:n]
  print(' '.join(x))

Submission status: Wrong Answer

Solution code:
n = int(input())

p = [-1]*501

q = 1

for i in range(1,n):
    for j in range(i+1,n+1):
        if p[i-j] == -1:
            if j == n:
                print(q)
            else:
                print(q,end = ' ')
            ind = q
            while ind <= len(p)-1:
                p[ind] = q
                ind += q*2
            q += 1
        else:
            if j==n:
                print(p[i-j])
            else:
                print(p[i-j],end = ' ')

Submission status: Wrong Answer

Solution code:
N = int(input())

if N%2==0:
        ans = []

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

                ans.append(ans_)



for a in ans:
        print(*a)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N=int(input())

ANS=[[0]*N for i in range(N)]


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

#print(ANS)

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
N = int(input())


if(N < 5):
    for i in range(1,N):
        ansList = []
        for j in range(i+1,N+1):
            if((i+j) % 2 == 1):
                ansList.append(1)
            else:
                ansList.append(2)
        print(' '.join(map(str, ansList)))
elif(N%2 == 0):
    for i in range(1,N):
        ansList = []
        for j in range(i+1,N+1):
            dif = j-i
            num = 0
            while(1):
                num += 1
                if(dif % 2 == 1):
                    break
                dif = dif // 2
            ansList.append(num)
        print(' '.join(map(str, ansList)))
else:
    for i in range(1,N):
        ansList = []
        for j in range(i+1,N+1):
            dif = j-i
            if(j == N):
                ansList.append(math.ceil(math.log2(N-2)+1))
            else:
                num = 0
                while(1):
                    num += 1
                    if(dif % 2 == 1):
                        break
                    dif = dif // 2
                ansList.append(num)
        print(' '.join(map(str, ansList)))

Submission status: Wrong Answer

Solution code:
#D問題
N = int(input())


for i in range(N-1):
    for j in range(N-i-1):
        if j%2 == 0:
            print(1,end=" ")
        else:
            if ((j-1)//2)%2 == 0:
                print(2,end=" ")
            else:
                print(3,end=" ")
    print()