結果

問題 No.1837 Same but Different
ユーザー chineristAC
提出日時 2022-02-11 22:15:47
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 59 ms / 2,000 ms
コード長 1,680 bytes
コンパイル時間 448 ms
コンパイル使用メモリ 82,396 KB
実行使用メモリ 68,548 KB
最終ジャッジ日時 2024-06-27 19:27:18
合計ジャッジ時間 3,141 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys,random,bisect
from collections import deque,defaultdict
from heapq import heapify,heappop,heappush
from itertools import permutations
from math import log,gcd

input = lambda :sys.stdin.readline()
mi = lambda :map(int,input().split())
li = lambda :list(mi())

N = int(input())

if N%3==0:
    A = [3*i for i in range(N)] + [10001]
    B = [3*i+1 for i in range(N)]
    tmp = N
    for i in range(N)[::-1]:
        while tmp and A[i]+3 < A[i+1]:
            A[i] += 3
            tmp -= 3
    
    assert tmp == 0
    print(*A[:N])
    print(*B)

elif N%3==1:
    A = [3*i for i in range(N)] + [10001]
    B = [3*i+1 for i in range(N)]
    tmp = N - 1
    A[-2] += 1
    for i in range(N)[::-1]:
        while tmp and A[i]+3 < A[i+1]:
            A[i] += 3
            tmp -= 3
    
    assert tmp==0
    print(*A[:N])
    print(*B)

else:
    A = [3*i for i in range(N)] + [10001]
    B = [3*i+1 for i in range(N)]
    if N >= 14:
        tmp = N - 14
        A[-2] += 7
        A[-3] += 7
    else:
        if N==5:
            A = [5,6,7,8,9]
            B = [1,2,3,4,25]
            print(*A)
            print(*B)
            exit()
        
        elif N==8:
            A = [10,11,12,13,14,15,16,17]
            B = [1,2,3,4,5,6,7,87]
            print(*A)
            print(*B)
            exit()
        
        elif N == 11:
            A = [30+i for i in range(11)]
            B = [1,2,3,4,5,6,7,8,9,10,sum(A)-55]
            print(*A)
            print(*B)
            exit()

    for i in range(N)[::-1]:
        while tmp and A[i]+3 < A[i+1]:
            A[i] += 3
            tmp -= 3
    
    #assert tmp==0
    print(*A[:N])
    print(*B)

    

    
0