QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#149040 | #3530. Small business | moon | WA | 2ms | 3616kb | C++20 | 1.5kb | 2023-08-23 22:59:24 | 2023-08-23 22:59:26 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf = numeric_limits<int>::max();
const ll inff = numeric_limits<ll>::max();
void solve() {
string s;
cin >> s;
int minn = inf;
int inx = -1;
int l = s.length();
for(int i = 0; i < l; ++i) {
if(minn > (s[i] - '0')) {
minn = s[i] - '0';
inx = i;
}
}
string ans = "";
for(int i = 0; i < l; ++i) {
if(i != inx) {
ans += s[i];
}
}
sort(ans.begin(), ans.end());
if(ans.length() >= 18) {
if(ans != "1000000000000000000") {
cout << "-1 -1";
return ;
}
}
if(ans[0] == '0') {
if(ans.length() == 1) {
cout << "0 0 ";
return ;
}
int inxx = -1;
for(int i = 0; i < l - 1; ++i) {
if(ans[i] != '0') {
inxx = i;
}
}
if(inxx == -1) {
cout << "-1 -1";
return ;
} else {
cout << minn << ' ';
cout << ans[inxx];
for(int i = 0; i < l - 1; ++i) {
if(i != inxx) {
cout << ans[i];
}
}
}
} else {
cout << minn << ' ' << ans;
}
}
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int cn = 1;
// cin >> cn;
while(cn--)
solve();
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 2ms
memory: 3616kb
input:
123456
output:
1 23456
result:
ok ok
Test #2:
score: 0
Accepted
time: 0ms
memory: 3528kb
input:
42
output:
2 4
result:
ok ok
Test #3:
score: 0
Accepted
time: 0ms
memory: 3608kb
input:
000
output:
-1 -1
result:
ok ok
Test #4:
score: -100
Wrong Answer
time: 0ms
memory: 3548kb
input:
4418409405
output:
0 901444458
result:
wrong answer jury has the better answer