結果

問題 No.694 square1001 and Permutation 3
ユーザー GrayCoderGrayCoder
提出日時 2018-06-08 23:40:33
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 449 bytes
コンパイル時間 173 ms
コンパイル使用メモリ 10,756 KB
実行使用メモリ 12,992 KB
最終ジャッジ日時 2023-09-13 00:25:52
合計ジャッジ時間 5,365 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 19 ms
12,776 KB
testcase_01 AC 18 ms
8,544 KB
testcase_02 AC 18 ms
8,552 KB
testcase_03 TLE -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
権限があれば一括ダウンロードができます

ソースコード

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