結果
問題 |
No.927 Second Permutation
|
ユーザー |
|
提出日時 | 2019-11-22 22:47:44 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,261 bytes |
コンパイル時間 | 1,347 ms |
コンパイル使用メモリ | 163,224 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-11 04:23:59 |
合計ジャッジ時間 | 2,301 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 10 WA * 17 |
ソースコード
#include <bits/stdc++.h> #define rep(i, n) for(int i=0; i<(n); ++i) #define rep1(i,n) for(int i=1; i<=(n); ++i) #define repi(i,a,b) for(int i=a; i<=(b); ++i) #define rrep(i,n) for(int i=(n-1); i>=0; --i) #define ALL(obj) (obj).begin(), (obj).end() #define RALL(obj) (obj).rbegin(), (obj).rend() #define pb push_back #define mp make_pair #define to_s to_string #define sz(v) (int)v.size() #define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() ) #define pr(x) cout<<(x)<<'\n' #define debug(x) cout << #x << ": " << (x) << '\n' #define yes "Yes" #define no "No" using namespace std; using ll = long long; using Edge = pair<int,long long>; using Graph = vector<vector<Edge>>; typedef pair<int,int> P; struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa; int MOD = 1e9 + 7; ll gcd(ll a,ll b){return b?gcd(b,a%b):a;} ll lcm(ll a,ll b){return (a*b)/gcd(a,b);} int dx[4]={1,0,-1,0}; int dy[4]={0,1,0,-1}; string solve(string X){ sort(ALL(X)); reverse(ALL(X)); string ans = X; char tp = ans[sz(X)-2]; ans[sz(X)-2] = ans[sz(X)-1]; ans[sz(X)-1] = tp; if(ans[0] == '0' || ans == X) return "-1"; else return ans; } int main(){ string X; cin >> X; pr(solve(X)); return 0; }