QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#149082 | #3530. Small business | moon | WA | 2ms | 3848kb | C++20 | 3.3kb | 2023-08-23 23:55:59 | 2023-08-23 23:56:01 |
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 l = s.length();
int zero = 0;
int one = 0;
int no = 0;
if(s == "00") {
cout << "0 0 ";
return ;
}
string test = "";
auto check = [&]() -> void {
if(l >= 38) {
if(zero == 36 && one == 2) {
cout << "1000000000000000000 1000000000000000000";
exit(0);
} else {
cout << "-1 -1";
exit(0);
}
}
if(no == 0) {
cout << "-1 -1";
exit(0);
}
if(zero == 19) {
if(one == 1 && no == 1) {
cout << "0 1000000000000000000";
exit(0);
} else {
cout << "-1 -1";
exit(0);
}
}
if(zero > 19 && one <= 1) {
cout << "-1 -1";
exit(0);
}
if(zero == 18 && one == 1) {
sort(test.begin(), test.end());
cout << test << ' ' << "1000000000000000000";
exit(0);
}
};
for(auto i : s) {
if(i == '0') {
zero++;
} else if(i == '1') {
one++;
}
if(i != '0') {
no++;
}
if(i != '0' && i != '1') {
test += i;
}
}
check();
int pre = l - 18;
sort(s.begin(), s.end());
// cout << s << '\n';
auto con = [&](string ss) -> string {
if(ss == "0") {
return "0";
}
string ans = "";
string res = "";
bool ok = true;
for(auto i : ss) {
if(i != '0' && ok) {
ans += i;
ok = false;
} else {
res += i;
}
}
return ans + res;
};
if(pre >= 1) {
string p = "";
string t = "";
for(auto i : s) {
if(p.length() < pre) {
p += i;
} else {
t += i;
}
}
s = t;
// cout << "p : ";
// cout << p << '\n';
// cout << "s : ";
// cout << s << '\n';
if(p[pre - 1] == '0' && pre > 1) {
p.pop_back();
string tem = "0";
bool ok = true;
for(auto i : s) {
if(i != '0' && ok) {
p += i;
ok = false;
} else {
tem += i;
}
}
s = tem;
}
// cout << "p : ";
// cout << p << '\n';
// cout << "s : ";
// cout << s << '\n';
if(p == "0") {
cout << p << ' ';
} else {
cout << con(p) << ' ';
}
cout << con(s);
} else {
string ans = "";
ans += s[0];
s.erase(s.begin());
cout << ans << ' ';
cout << con(s);
}
}
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: 3788kb
input:
123456
output:
1 23456
result:
ok ok
Test #2:
score: 0
Accepted
time: 1ms
memory: 3848kb
input:
42
output:
2 4
result:
ok ok
Test #3:
score: 0
Accepted
time: 1ms
memory: 3584kb
input:
000
output:
-1 -1
result:
ok ok
Test #4:
score: 0
Accepted
time: 1ms
memory: 3500kb
input:
4418409405
output:
0 104444589
result:
ok ok
Test #5:
score: 0
Accepted
time: 1ms
memory: 3612kb
input:
82933602294918208962
output:
10 202222334668889999
result:
ok ok
Test #6:
score: 0
Accepted
time: 1ms
memory: 3768kb
input:
264727800857314294187884421131
output:
100111122223 344444567777888889
result:
ok ok
Test #7:
score: 0
Accepted
time: 1ms
memory: 3648kb
input:
5879012924529447774473489599650098351318
output:
-1 -1
result:
ok ok
Test #8:
score: 0
Accepted
time: 1ms
memory: 3536kb
input:
61899560303187317666207432000671179900997026617305
output:
-1 -1
result:
ok ok
Test #9:
score: 0
Accepted
time: 1ms
memory: 3556kb
input:
0
output:
-1 -1
result:
ok ok
Test #10:
score: -100
Wrong Answer
time: 1ms
memory: 3568kb
input:
0000000000000000010
output:
1000000000000000000
result:
wrong output format Unexpected character '