結果
問題 |
No.927 Second Permutation
|
ユーザー |
![]() |
提出日時 | 2020-01-13 19:43:17 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 503 bytes |
コンパイル時間 | 697 ms |
コンパイル使用メモリ | 67,584 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-21 14:56:33 |
合計ジャッジ時間 | 1,885 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 1 |
other | AC * 6 WA * 21 |
ソースコード
#include <iostream> #include <string.h> #include <algorithm> using namespace std; int main(){ int i,j,k,len,count=0; char X[20],tmp,tmp_s[20]; int max; cin>>X; strcpy(tmp_s,X); len=strlen(X); for(i=0;i<len;i++){ max=i; for(j=i+1;j<len;j++){ if(X[max]<X[j]) max=j; } tmp=X[i]; X[i]=X[max]; X[max]=tmp; } j=len-1; while(X[j]==X[j-1] && j>1){ j--; } tmp=X[j-1]; X[j-1]=X[j]; X[j]=tmp; if(X[0]=='0'){ cout<<"-1"<<'\n'; return 0; } cout<<X<<endl; return 0; }