QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#149040#3530. Small businessmoonWA 2ms3616kbC++201.5kb2023-08-23 22:59:242023-08-23 22:59:26

Judging History

This is the latest submission verdict.

  • [2023-08-23 22:59:26]
  • Judged
  • Verdict: WA
  • Time: 2ms
  • Memory: 3616kb
  • [2023-08-23 22:59:24]
  • 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 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;
}

Details

Tip: Click on the bar to expand more detailed information

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