QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#148689 | #3530. Small business | OneWan | WA | 1ms | 3572kb | C++20 | 2.2kb | 2023-08-23 17:33:38 | 2023-08-23 20:26:21 |
Judging History
answer
// Problem: B - Small business
// Contest: Virtual Judge - Namomo Summer Camp 23 Day 3
// URL: https://vjudge.net/contest/577185#problem/B
// Memory Limit: 254 MB
// Time Limit: 1000 ms
#include <bits/stdc++.h>
using namespace std;
// 2023 OneWan
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
string str;
cin >> str;
if (str.size() > 40) {
cout << -1 << " " << -1 << "\n";
} else {
vector<int> a(27);
for (int i = 0 ; i < str.size() ; i++) {
a[str[i] ^ 48]++;
}
int len = str.size();
for (int L = 1 ; L < len ; L++) {
auto b = a;
int R = len - L;
__int128 x = 0, y = 0;
if (L == 1) {
bool flag = true;
for (int i = 0 ; i < 10 ; i++) {
if (b[i]) {
b[i]--;
x = i;
flag = false;
break;
}
}
if (flag) {
x = 2000000000000000000LL;
}
} else {
bool flag = true;
for (int i = 1 ; i < 10 ; i++) {
if (b[i]) {
b[i]--;
x = i;
flag = false;
break;
}
}
if (flag) {
x = 2000000000000000000LL;
} else {
for (int cnt = 1 ; cnt < L ; cnt++) {
for (int i = 0 ; i < 10 ; i++) {
if (b[i]) {
b[i]--;
x = x * 10 + i;
break;
}
}
}
}
}
if (R == 1) {
bool flag = true;
for (int i = 0 ; i < 10 ; i++) {
if (b[i]) {
b[i]--;
y = i;
flag = false;
break;
}
}
if (flag) {
y = 2000000000000000000LL;
}
} else {
bool flag = true;
for (int i = 1 ; i < 10 ; i++) {
if (b[i]) {
b[i]--;
y = i;
flag = false;
break;
}
}
if (flag) {
y = 2000000000000000000LL;
} else {
for (int cnt = 1 ; cnt < R ; cnt++) {
for (int i = 0 ; i < 10 ; i++) {
if (b[i]) {
b[i]--;
y = y * 10 + i;
break;
}
}
}
}
}
if (x <= 1000000000000000000LL && y <= 1000000000000000000LL) {
if (x > y) swap(x, y);
cout << (long long) x << " " << (long long) y << "\n";
return 0;
}
}
cout << -1 << " " << -1 << "\n";
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3464kb
input:
123456
output:
1 23456
result:
ok ok
Test #2:
score: 0
Accepted
time: 0ms
memory: 3460kb
input:
42
output:
2 4
result:
ok ok
Test #3:
score: 0
Accepted
time: 1ms
memory: 3456kb
input:
000
output:
-1 -1
result:
ok ok
Test #4:
score: 0
Accepted
time: 0ms
memory: 3456kb
input:
4418409405
output:
0 104444589
result:
ok ok
Test #5:
score: 0
Accepted
time: 1ms
memory: 3456kb
input:
82933602294918208962
output:
10 202222334668889999
result:
ok ok
Test #6:
score: 0
Accepted
time: 1ms
memory: 3460kb
input:
264727800857314294187884421131
output:
100111122223 344444567777888889
result:
ok ok
Test #7:
score: 0
Accepted
time: 0ms
memory: 3520kb
input:
5879012924529447774473489599650098351318
output:
-1 -1
result:
ok ok
Test #8:
score: 0
Accepted
time: 1ms
memory: 3468kb
input:
61899560303187317666207432000671179900997026617305
output:
-1 -1
result:
ok ok
Test #9:
score: 0
Accepted
time: 1ms
memory: 3484kb
input:
0
output:
-1 -1
result:
ok ok
Test #10:
score: 0
Accepted
time: 1ms
memory: 3456kb
input:
0000000000000000010
output:
0 100000000000000000
result:
ok ok
Test #11:
score: 0
Accepted
time: 0ms
memory: 3428kb
input:
72
output:
2 7
result:
ok ok
Test #12:
score: 0
Accepted
time: 1ms
memory: 3460kb
input:
9407809440087866606
output:
0 400004466667788899
result:
ok ok
Test #13:
score: 0
Accepted
time: 1ms
memory: 3572kb
input:
89809008899888899001
output:
10 800008888888999999
result:
ok ok
Test #14:
score: 0
Accepted
time: 1ms
memory: 3496kb
input:
5977998750
output:
0 557778999
result:
ok ok
Test #15:
score: 0
Accepted
time: 0ms
memory: 3456kb
input:
079968486310868706
output:
0 10034666677888899
result:
ok ok
Test #16:
score: 0
Accepted
time: 1ms
memory: 3472kb
input:
8863679763487438575
output:
3 334455666777788889
result:
ok ok
Test #17:
score: 0
Accepted
time: 0ms
memory: 3480kb
input:
89989959979978899897
output:
57 778888899999999999
result:
ok ok
Test #18:
score: 0
Accepted
time: 1ms
memory: 3456kb
input:
04
output:
0 4
result:
ok ok
Test #19:
score: 0
Accepted
time: 1ms
memory: 3572kb
input:
050
output:
0 50
result:
ok ok
Test #20:
score: 0
Accepted
time: 1ms
memory: 3460kb
input:
00600
output:
0 6000
result:
ok ok
Test #21:
score: -100
Wrong Answer
time: 1ms
memory: 3468kb
input:
00000004000000000001
output:
10 400000000000000000
result:
wrong answer jury has the better answer