結果
問題 | No.39 桁の数字を入れ替え |
ユーザー | ScottShelby |
提出日時 | 2020-09-02 08:26:05 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 556 bytes |
コンパイル時間 | 1,647 ms |
コンパイル使用メモリ | 167,500 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-05-01 10:24:17 |
合計ジャッジ時間 | 2,194 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
6,812 KB |
testcase_01 | AC | 1 ms
6,940 KB |
testcase_02 | AC | 2 ms
6,944 KB |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | AC | 1 ms
6,940 KB |
testcase_08 | AC | 2 ms
6,940 KB |
testcase_09 | AC | 2 ms
6,940 KB |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | AC | 2 ms
6,940 KB |
testcase_15 | AC | 2 ms
6,944 KB |
testcase_16 | AC | 1 ms
6,940 KB |
testcase_17 | WA | - |
testcase_18 | AC | 1 ms
6,944 KB |
コンパイルメッセージ
main.cpp: In function 'int main()': main.cpp:21:22: warning: 'minc' may be used uninitialized [-Wmaybe-uninitialized] 21 | int minc = s[minc] - '0'; | ^ main.cpp:21:9: note: 'minc' was declared here 21 | int minc = s[minc] - '0'; | ^~~~
ソースコード
#include<bits/stdc++.h> #define rep(i,N) for(ll (i)=0;(i)<(N);(i)++) #define chmax(x,y) x=max(x,y) #define chmin(x,y) x=min(x,y) using namespace std; typedef long long ll; typedef pair<int,int> P; const int mod = 1000000007; const int INF = 1001001001; int main() { string s; cin >> s; int maxp = 0; int minp = 0; int n = s.length(); rep(i, n) { int c = s[i] - '0'; int maxc = s[maxp] - '0'; int minc = s[minc] - '0'; if (maxc <= c) maxp = i; if (minc > c) minp = i; } swap(s[minp], s[maxp]); cout << s << endl; }