結果

問題 No.2745 String Swap Battle
ユーザー 👑 rin204rin204
提出日時 2024-04-20 14:23:13
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 813 bytes
コンパイル時間 144 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 87,108 KB
最終ジャッジ日時 2024-04-20 14:23:20
合計ジャッジ時間 2,569 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 62 ms
75,620 KB
testcase_01 AC 60 ms
75,884 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 42 ms
58,772 KB
testcase_05 AC 42 ms
58,880 KB
testcase_06 AC 65 ms
75,520 KB
testcase_07 AC 59 ms
76,032 KB
testcase_08 AC 60 ms
75,648 KB
testcase_09 AC 60 ms
75,544 KB
testcase_10 AC 53 ms
70,656 KB
testcase_11 AC 52 ms
66,944 KB
testcase_12 AC 187 ms
87,108 KB
testcase_13 AC 188 ms
86,528 KB
testcase_14 AC 160 ms
86,704 KB
testcase_15 AC 90 ms
76,288 KB
testcase_16 AC 84 ms
76,160 KB
testcase_17 AC 79 ms
76,288 KB
testcase_18 AC 36 ms
51,712 KB
testcase_19 AC 36 ms
51,840 KB
testcase_20 AC 36 ms
51,840 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
S = [input() for _ in range(n)]
for i in range(n):
    T = S[i]
    mi = "z"
    m = len(T)
    ind = -1
    for j in range(1, m):
        if T[j - 1] > T[j] and T[j] <= mi:
            mi = T[j]
            ind = j
        elif T[j] == mi:
            ind = j

    if ind == -1:
        change = True
        for j in range(1, m):
            if T[j] == T[j - 1]:
                change = False
                break
        if change:
            T = T[:-2] + T[-1] + T[-2]
        S[i] = T
        continue

    for j in range(m):
        if T[j] > mi:
            T = T[:j] + T[ind] + T[j + 1 : ind] + T[j] + T[ind + 1 :]
            S[i] = T
            break

mi = min(S)
c = S.count(mi)
ans = [0] * n
for i in range(n):
    if S[i] == mi:
        ans[i] = n + 1 - c

print(*ans, sep="\n")
0