結果
問題 |
No.39 桁の数字を入れ替え
|
ユーザー |
![]() |
提出日時 | 2018-04-23 23:33:57 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 755 bytes |
コンパイル時間 | 534 ms |
コンパイル使用メモリ | 72,992 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-27 14:09:47 |
合計ジャッジ時間 | 1,194 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 15 WA * 4 |
ソースコード
#include <iostream> #include <vector> #include <algorithm> #include <math.h> #include <map> #include <set> #include <queue> #include <stack> #define ALL(x) (x).begin(),(x).end() #define RALL(x) (x).rbegin(),(x).rend() #define REP(i,a,n) for(int i = (a);i < (n);i++) #define PI 3.14159265359 #define MOD 1000007 #define chmax(a,b) if(a < b)a = b using namespace std; int main(){ string s; cin >> s; int m,index = 0,j; for(j = 0;j < s.length();j++){ m = s[j]-'0',index = j; for(int i = s.length()-1;i > j;i--){ if(m < s[i]-'0'){ m = s[i]-'0'; index = i; } } if(index != j)break; } swap(s[j], s[index]); cout << s << endl; return 0; }