結果

問題 No.39 桁の数字を入れ替え
ユーザー byamibyami
提出日時 2018-01-15 19:00:15
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 417 bytes
コンパイル時間 1,489 ms
コンパイル使用メモリ 165,304 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-08-25 17:16:52
合計ジャッジ時間 2,750 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,384 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 2 ms
4,384 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 WA -
testcase_18 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内:
main.cpp:16:9: 警告: ‘a’ may be used uninitialized [-Wmaybe-uninitialized]
   16 |         if (s[i] == a) {
      |         ^~
main.cpp:8:9: 備考: ‘a’ はここで定義されています
    8 |     int a;
      |         ^

ソースコード

diff #

#include<bits/stdc++.h>
#define rep(i,a,n) for (int i = a; i < n; i++)
#define per(i,n,a) for (int i = n - 1; i >= a; i--)
using namespace std;

int main() {
    string s;
    int a;
    cin >> s;
    rep(i, 0, s.size()) {
        if (s[i] < s[i + 1]) {
            a = s[i + 1];
        }
    }
    per(i, s.size(), 0) {
        if (s[i] == a) {
            swap(s[0], s[i]);
        }
    }
    cout << s << endl;
}
0