結果
問題 | No.39 桁の数字を入れ替え |
ユーザー |
![]() |
提出日時 | 2014-10-15 01:10:30 |
言語 | D (dmd 2.109.1) |
結果 |
AC
|
実行時間 | 1 ms / 5,000 ms |
コード長 | 557 bytes |
コンパイル時間 | 887 ms |
コンパイル使用メモリ | 106,344 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-12 01:27:32 |
合計ジャッジ時間 | 1,778 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 19 |
ソースコード
import std.stdio, std.string, std.conv ,std.array,std.algorithm, std.range ,std.math; void main(){ auto N = readln().strip().to!string().array(); dchar[] sorted = N.dup; auto ind = iota(0, N.length).array(); sorted.sort!("a > b")(); int i = 0; while(i < N.length && N[i] == sorted[i]) ++i; int p; if ( i != N.length ) { foreach_reverse(immutable int j; 0 .. N.length.to!int){ if(sorted[i] == N[j]) { p = j; break; } } swap(N[i], N[p]); } writeln(N); return; }