結果

問題 No.694 square1001 and Permutation 3
ユーザー GrayCoder
提出日時 2018-06-08 23:40:33
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
TLE  
実行時間 -
コード長 449 bytes
コンパイル時間 139 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 17,820 KB
最終ジャッジ日時 2024-06-30 11:12:23
合計ジャッジ時間 5,294 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample -- * 1
other AC * 3 TLE * 1 -- * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque
from sys import stdin

def main():
    N = int(input())
    A = stdin.read().splitlines()
    A = list(map(int, A))

    for n in range(N):
        a = deque(A)
        a.rotate(-n)
        print(program(a, N))

def program(a, n):
    cnt = 0
    for i in range(n):
        for j in range(n - 1):
            if a[j] > a[j+1]:
                a[j], a[j+1] = a[j+1], a[j]
                cnt += 1
    return cnt

main()
0