結果

問題 No.927 Second Permutation
ユーザー fujicoderfujicoder
提出日時 2019-11-22 21:53:06
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 869 bytes
コンパイル時間 770 ms
コンパイル使用メモリ 86,148 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-19 11:07:38
合計ジャッジ時間 1,874 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 6 ms
5,376 KB
testcase_25 AC 4 ms
5,376 KB
testcase_26 AC 4 ms
5,376 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<string>
#include <vector>
#include<queue>
#include<map>
#include<algorithm>
#include<iomanip>
#include<cmath>
#include<bitset>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using pii = pair<int, int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define vsort(v) sort(v.begin(), v.end())
#define rv(v) reverse(v.begin(), v.end())
#define ll long long
#define PI 3.141592653589793
using vll = vector<ll>;
using Graph = vii;
const ll MOD = 998244353;

int main() {
	string x, t;
	cin >> x;
	t = x;
	vsort(x);
	vsort(t);
	ll n = t.size();
	if (t[0] == t[n - 1] || t[n - 1] == '0') {
		cout << -1 << endl;
		return 0;
	}
	t[0] = x[1];
	t[1] = x[0];
	ll ans = 0;
	rep(i, n) {
		int k = t[i] - '0';
		ans += k * pow(10.0, i);
	}
	cout << ans << endl;
	return 0;
}
0