結果

問題 No.927 Second Permutation
ユーザー santafe1006santafe1006
提出日時 2019-12-15 20:57:46
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 34 ms / 2,000 ms
コード長 354 bytes
コンパイル時間 76 ms
コンパイル使用メモリ 10,624 KB
実行使用メモリ 9,284 KB
最終ジャッジ日時 2023-09-15 15:41:23
合計ジャッジ時間 1,828 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,868 KB
testcase_01 AC 14 ms
7,708 KB
testcase_02 AC 14 ms
7,860 KB
testcase_03 AC 14 ms
7,772 KB
testcase_04 AC 14 ms
7,888 KB
testcase_05 AC 14 ms
7,884 KB
testcase_06 AC 14 ms
7,748 KB
testcase_07 AC 14 ms
7,708 KB
testcase_08 AC 21 ms
8,312 KB
testcase_09 AC 14 ms
7,752 KB
testcase_10 AC 24 ms
8,624 KB
testcase_11 AC 31 ms
9,136 KB
testcase_12 AC 22 ms
8,384 KB
testcase_13 AC 15 ms
7,996 KB
testcase_14 AC 25 ms
8,536 KB
testcase_15 AC 22 ms
8,344 KB
testcase_16 AC 33 ms
9,184 KB
testcase_17 AC 32 ms
9,232 KB
testcase_18 AC 33 ms
9,284 KB
testcase_19 AC 33 ms
9,136 KB
testcase_20 AC 33 ms
9,116 KB
testcase_21 AC 33 ms
9,136 KB
testcase_22 AC 32 ms
9,176 KB
testcase_23 AC 34 ms
9,112 KB
testcase_24 AC 18 ms
8,800 KB
testcase_25 AC 16 ms
8,676 KB
testcase_26 AC 15 ms
8,416 KB
testcase_27 AC 15 ms
7,972 KB
testcase_28 AC 15 ms
8,028 KB
testcase_29 AC 15 ms
8,008 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

s = input()
if s.count('0') >= len(s)-1:
  res = -1
else:
  s1 = list(s)
  if len(set(s1)) == 1:
    res = -1
  else:
    s1.sort()
    sw = ''
    for i in range(len(s1)-1):
      if s1[i] != s1[i+1]:
        sw = s1[i]
        s1[i] = s1[i+1]
        s1[i+1] = sw
        break
      else:
        pass
    s1.reverse()
    res = ''.join(s1)
print(res)
0