結果
| 問題 |
No.39 桁の数字を入れ替え
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-11-03 00:03:15 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 552 bytes |
| コンパイル時間 | 1,483 ms |
| コンパイル使用メモリ | 168,400 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-07-22 08:32:22 |
| 合計ジャッジ時間 | 2,271 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 11 WA * 8 |
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:25:17: warning: 'f' may be used uninitialized [-Wmaybe-uninitialized]
25 | swap(n[0], n[f]);
| ^
main.cpp:22:7: note: 'f' was declared here
22 | int f;
| ^
ソースコード
#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;
}