QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#149098#3530. Small businessmoonWA 2ms3844kbC++203.7kb2023-08-24 00:41:182023-08-24 00:41:22

Judging History

This is the latest submission verdict.

  • [2023-08-24 00:41:22]
  • Judged
  • Verdict: WA
  • Time: 2ms
  • Memory: 3844kb
  • [2023-08-24 00:41:18]
  • Submitted

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 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;
    };
    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 && no < 2) {
            cout << "-1 -1";
            exit(0);
        }
        if(zero >= 18 && one >= 1) {
            int temz = 0;
            int temo = 0;
            string maxx = "";
            string ans = "";
            for(auto i : s) {
                if(temz < 18 && i == '0') {
                    temz++;
                } else if(temo < 1 && i == '1') {
                    temo++;
                } else {
                    ans += i;
                }
            }
            sort(ans.begin(), ans.end());
            if(ans.length() >= 2 && ans.back() == '0') {
                cout << "-1 -1";
                exit(0);
            }
            if(ans == "") {
                cout << "0 100000000000000000";
                exit(0);
            }
            cout << con(ans) << " 1000000000000000000";
            exit(0);
        }
        if(no < 2) {
            cout << "-1 -1";
            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';
    
    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';
        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;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 3784kb

input:

123456

output:

1 23456

result:

ok ok

Test #2:

score: 0
Accepted
time: 2ms
memory: 3504kb

input:

42

output:

2 4

result:

ok ok

Test #3:

score: 0
Accepted
time: 2ms
memory: 3648kb

input:

000

output:

-1 -1

result:

ok ok

Test #4:

score: 0
Accepted
time: 2ms
memory: 3592kb

input:

4418409405

output:

0 104444589

result:

ok ok

Test #5:

score: 0
Accepted
time: 2ms
memory: 3844kb

input:

82933602294918208962

output:

10 202222334668889999

result:

ok ok

Test #6:

score: 0
Accepted
time: 0ms
memory: 3644kb

input:

264727800857314294187884421131

output:

100111122223 344444567777888889

result:

ok ok

Test #7:

score: 0
Accepted
time: 2ms
memory: 3596kb

input:

5879012924529447774473489599650098351318

output:

-1 -1

result:

ok ok

Test #8:

score: 0
Accepted
time: 1ms
memory: 3792kb

input:

61899560303187317666207432000671179900997026617305

output:

-1 -1

result:

ok ok

Test #9:

score: 0
Accepted
time: 1ms
memory: 3536kb

input:

0

output:

-1 -1

result:

ok ok

Test #10:

score: 0
Accepted
time: 1ms
memory: 3536kb

input:

0000000000000000010

output:

0 100000000000000000

result:

ok ok

Test #11:

score: 0
Accepted
time: 1ms
memory: 3584kb

input:

72

output:

2 7

result:

ok ok

Test #12:

score: 0
Accepted
time: 1ms
memory: 3648kb

input:

9407809440087866606

output:

0 400004466667788899

result:

ok ok

Test #13:

score: 0
Accepted
time: 0ms
memory: 3612kb

input:

89809008899888899001

output:

10 800008888888999999

result:

ok ok

Test #14:

score: 0
Accepted
time: 1ms
memory: 3764kb

input:

5977998750

output:

0 557778999

result:

ok ok

Test #15:

score: 0
Accepted
time: 1ms
memory: 3788kb

input:

079968486310868706

output:

0 10034666677888899

result:

ok ok

Test #16:

score: 0
Accepted
time: 1ms
memory: 3592kb

input:

8863679763487438575

output:

3 334455666777788889

result:

ok ok

Test #17:

score: 0
Accepted
time: 1ms
memory: 3552kb

input:

89989959979978899897

output:

57 778888899999999999

result:

ok ok

Test #18:

score: -100
Wrong Answer
time: 1ms
memory: 3552kb

input:

04

output:

-1 -1

result:

wrong answer jury has the better answer