結果
問題 | No.39 桁の数字を入れ替え |
ユーザー |
|
提出日時 | 2017-12-15 02:51:23 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 895 bytes |
コンパイル時間 | 1,536 ms |
コンパイル使用メモリ | 167,152 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-12-14 13:56:54 |
合計ジャッジ時間 | 2,246 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 15 WA * 4 |
ソースコード
#include <bits/stdc++.h>#define FOR(i,a,b) for(int i = (a); i < (b); ++i)#define REP(i,n) FOR(i,0,n)#define SZ(n) (int)(n).size()#define ALL(n) (n).begin(), (n).end()#define MOD 1000003#define INF 100000000using namespace std;typedef long long LL;typedef vector<int> VI;typedef pair<int, int> PI;int main() {string n;cin >> n;int np[16];REP(i, SZ(n)) {np[i] = n[i];}int m[2] = {};bool bo = false;REP(i, SZ(n)) {if (m[0] < np[i]) {m[0] = np[i];m[1] = i;}else if (m[0] == np[i]) {m[1] = i;bo = true;}else;}REP(i, SZ(n)) {if (np[0] == m[0] && !bo) break;if (np[0] == m[0] && bo) {REP(i, SZ(n)) {if (np[i] != m[0]) {swap(np[i], np[m[1]]);break;}}break;}if (np[i] < m[0]) {swap(np[m[1]], np[i]);break;}}REP(i, SZ(n)) {cout << char(np[i]);}cout << endl;return 0;}