結果
| 問題 |
No.39 桁の数字を入れ替え
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-06-15 14:55:30 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 562 bytes |
| コンパイル時間 | 1,196 ms |
| コンパイル使用メモリ | 157,544 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-06-30 14:48:44 |
| 合計ジャッジ時間 | 1,917 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 17 WA * 2 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:12:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
12 | scanf("%s", s);
| ~~~~~^~~~~~~~~
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
char s[100];
int n, k, m;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
scanf("%s", s);
n = strlen(s);
for (int i = 0; i < n; i++) {
m = 0;
for (int j = i +1; s[j]; j++) {
if (s[j] > m)
m = s[k=j];
}
if (s[i] < m) {
char t = s[k];
s[k] = s[i];
s[i] = t;
break;
}
}
printf("%s\n", s);
return 0;
}