CSES - Datatähti Open 2021 - Results
Submission details
Task:Greater Integers
Sender:lookcook
Submission time:2021-01-30 16:51:47 +0200
Language:C++ (C++17)
Status:READY
Result:100
Feedback
groupverdictscore
#1ACCEPTED35
#2ACCEPTED65
Test results
testverdicttimegroup
#1ACCEPTED0.01 s1, 2details
#2ACCEPTED0.01 s2details

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:16:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int i = 1; i < s.length(); i++) {
                         ~~^~~~~~~~~~~~

Code

#include <bits/stdc++.h>

#define int long long

using namespace std;

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int t;
    cin >> t;
    while (t--) {
        string s;
        cin >> s;
        bool flag = false;
        for (int i = 1; i < s.length(); i++) {
            if (s[i]-'0'<s[0]-'0') flag = true;
            else if (s[i]-'0'>s[0]-'0') break;
        }
        int sz = s.length();
        if (s[0] == '9' && !flag) sz++;
        int digit = s[0]-'0';
        if (!flag) {
            if (digit == 9) digit = 1;
            else digit++;
        }
        string res = "";
        for (int i = 0; i < sz; i++) res += (char)(digit+'0');
        cout << res << '\n';
    }
}
/*

*/

Test details

Test 1

Group: 1, 2

Verdict: ACCEPTED

input
1000
1
2
3
4
...

correct output
2
3
4
5
6
...

user output
2
3
4
5
6
...
Truncated

Test 2

Group: 2

Verdict: ACCEPTED

input
1000
735425311146082632
756615631808964686
466489470801941584
100417544394053220
...

correct output
777777777777777777
777777777777777777
555555555555555555
111111111111111111
555555555555555555
...

user output
777777777777777777
777777777777777777
555555555555555555
111111111111111111
55555555555555
...
Truncated