結果

問題 No.39 桁の数字を入れ替え
ユーザー hkjakhkjak
提出日時 2020-11-03 00:03:15
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 552 bytes
コンパイル時間 1,409 ms
コンパイル使用メモリ 165,512 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-09-29 14:20:06
合計ジャッジ時間 2,226 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 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 AC 1 ms
4,380 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内:
main.cpp:25:17: 警告: ‘f’ may be used uninitialized [-Wmaybe-uninitialized]
   25 |   swap(n[0], n[f]);
      |                 ^
main.cpp:22:7: 備考: ‘f’ はここで定義されています
   22 |   int f;
      |       ^

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rep1(i, n) for(int i=1; i<=(int)(n); i++)
#define rep2(i, n, m) for(int i=(int)n; i<=(int)m; i++)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> wi;
typedef vector<ll> vl;
const ll inf=1LL<<60;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  string n;
  cin >> n;

  int m=0;
  rep(i, n.size())m=max(m, n[i]-'0');

  int f;
  rep(i, n.size())if(n[i]-'0'==m)f=i;

  swap(n[0], n[f]);

  cout << n << endl;

  return 0;
}
0