提出 #577168
ソースコード 拡げる
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric> //cout<<fixed<<setprecision(10);
//#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
//#include <memory.h>
#include <cassert>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) ((int)strlen(X))
#define F first
#define S second
#define IOS ios_base::sync_with_stdio(0)
#ifdef ONLINE_JUDGE
#define FILEIO(name) \
freopen(name".in", "r", stdin); \
freopen(name".out", "w", stdout);
#else
#define FILEIO(name)
#endif
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef pair<ll,ll> pll;
/*#include<complex>
typedef complex<double> cd;
#define X real()
#define Y imag()*/
ll x;
bitset<20> bs;
ll ans=0,ma=-9e18,N;
ll dif(ll A,ll B){
ll ret=A-B;
if(ret<0)ret=-ret;
return ret;
}
void go(ll now,int L){
if(L==0){
ll tmp=min(dif(now,x),N-dif(now,x));
if(tmp>ma){
ma=tmp;
ans=now;
}
return;
}
for(int i=0;i<10;i++){
if(bs[i])continue;
bs[i]=1;
go(now*10+i,L-1);
bs[i]=0;
}
}
char ANS[20],S[20];
int main()
{
RS(S);
x=0;
REP(i,0,LEN(S))x=x*10+S[i]-'0';
N=1;
ll zz=x,L=0;
for(;zz>0;){
N*=10;
zz/=10;
L++;
}
REP(i,0,LEN(S)){
if(S[i]!='0')break;
N*=10;
L++;
}
REP(i,0,10){
bs[i]=1;
go(i,L-1);
bs[i]=0;
}
sprintf(ANS,"%lld",ans);
if(LEN(ANS)<L)
cout<<0<<ans<<endl;
else
cout<<ans<<endl;
return 0;
}
提出情報
提出日時
2015-11-22 11:26:37+0900
問題
B - Change a Password
ユーザ
HDYTTO
言語
C++11 (GCC 4.8.1)
得点
100
コード長
2563 Byte
結果
AC
実行時間
243 ms
メモリ
1052 KiB
コンパイルエラー
./Main.cpp: In function ‘int main()’:
./Main.cpp:93:10: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
RS(S);
^
ジャッジ結果
セット名
All
得点 / 配点
100 / 100
結果
セット名
テストケース
All
00_test_00, 00_test_01, 00_test_02, 00_test_03, 01_rand_00, 01_rand_01, 01_rand_02, 01_rand_03, 01_rand_04, 01_rand_05, 01_rand_06, 01_rand_07, 01_rand_08, 01_rand_09, 01_rand_10, 01_rand_11, 01_rand_12, 01_rand_13, 01_rand_14, 01_rand_15, 01_rand_16, 01_rand_17, 01_rand_18, 01_rand_19, 01_rand_20, 01_rand_21, 01_rand_22, 01_rand_23, 01_rand_24, 01_rand_25, 01_rand_26, 01_rand_27, 01_rand_28, 01_rand_29, 01_rand_30, 01_rand_31, 01_rand_32, 01_rand_33, 01_rand_34, 01_rand_35, 01_rand_36, 01_rand_37, 01_rand_38, 01_rand_39, 01_rand_40, 01_rand_41, 01_rand_42, 01_rand_43, 01_rand_44, 01_rand_45, 01_rand_46, 01_rand_47, 01_rand_48, 01_rand_49, 99_handmake_00, 99_handmake_01, 99_handmake_02, 99_handmake_03, 99_handmake_04, 99_handmake_05, 99_handmake_06
ケース名
結果
実行時間
メモリ
00_test_00
AC
25 ms
1044 KiB
00_test_01
AC
24 ms
1048 KiB
00_test_02
AC
26 ms
1048 KiB
00_test_03
AC
152 ms
1052 KiB
01_rand_00
AC
74 ms
1048 KiB
01_rand_01
AC
150 ms
1048 KiB
01_rand_02
AC
74 ms
1048 KiB
01_rand_03
AC
29 ms
1048 KiB
01_rand_04
AC
29 ms
1048 KiB
01_rand_05
AC
29 ms
1044 KiB
01_rand_06
AC
30 ms
976 KiB
01_rand_07
AC
40 ms
1044 KiB
01_rand_08
AC
78 ms
936 KiB
01_rand_09
AC
241 ms
1044 KiB
01_rand_10
AC
24 ms
1044 KiB
01_rand_11
AC
25 ms
1044 KiB
01_rand_12
AC
27 ms
1044 KiB
01_rand_13
AC
149 ms
1052 KiB
01_rand_14
AC
26 ms
1044 KiB
01_rand_15
AC
40 ms
1044 KiB
01_rand_16
AC
26 ms
1048 KiB
01_rand_17
AC
74 ms
1044 KiB
01_rand_18
AC
26 ms
1048 KiB
01_rand_19
AC
29 ms
1048 KiB
01_rand_20
AC
26 ms
1044 KiB
01_rand_21
AC
26 ms
1048 KiB
01_rand_22
AC
243 ms
1048 KiB
01_rand_23
AC
25 ms
1044 KiB
01_rand_24
AC
24 ms
1028 KiB
01_rand_25
AC
75 ms
1052 KiB
01_rand_26
AC
242 ms
1052 KiB
01_rand_27
AC
26 ms
1048 KiB
01_rand_28
AC
76 ms
1048 KiB
01_rand_29
AC
243 ms
1040 KiB
01_rand_30
AC
40 ms
1048 KiB
01_rand_31
AC
241 ms
1048 KiB
01_rand_32
AC
25 ms
1044 KiB
01_rand_33
AC
24 ms
1048 KiB
01_rand_34
AC
74 ms
1044 KiB
01_rand_35
AC
27 ms
1044 KiB
01_rand_36
AC
41 ms
1048 KiB
01_rand_37
AC
26 ms
1048 KiB
01_rand_38
AC
26 ms
1044 KiB
01_rand_39
AC
39 ms
1044 KiB
01_rand_40
AC
240 ms
1036 KiB
01_rand_41
AC
41 ms
1048 KiB
01_rand_42
AC
27 ms
1044 KiB
01_rand_43
AC
241 ms
1048 KiB
01_rand_44
AC
38 ms
1048 KiB
01_rand_45
AC
25 ms
1044 KiB
01_rand_46
AC
40 ms
1044 KiB
01_rand_47
AC
153 ms
1044 KiB
01_rand_48
AC
26 ms
1048 KiB
01_rand_49
AC
26 ms
1048 KiB
99_handmake_00
AC
243 ms
1048 KiB
99_handmake_01
AC
239 ms
1036 KiB
99_handmake_02
AC
240 ms
1036 KiB
99_handmake_03
AC
239 ms
1036 KiB
99_handmake_04
AC
240 ms
980 KiB
99_handmake_05
AC
239 ms
1040 KiB
99_handmake_06
AC
239 ms
1044 KiB