CSES - Datatähti Open 2021 - Results
Submission details
Task:Greater Integers
Sender:Norimo2
Submission time:2021-01-30 12:31:16 +0200
Language:C++ (C++17)
Status:READY
Result:0
Feedback
groupverdictscore
#10
#20
Test results
testverdicttimegroup
#10.01 s1, 2details
#20.01 s2details

Compiler report

input/code.cpp: In function 'void solve()':
input/code.cpp:102:5: warning: 'n' may be used uninitialized in this function [-Wmaybe-uninitialized]
     if(ans1 <= n)
     ^~

Code

# include <iostream>
# include <cmath>
# include <algorithm>
# include <stdio.h>
# include <cstdint>
# include <cstring>
# include <string>
# include <cstdlib>
# include <vector>
# include <bitset>
# include <map>
# include <queue>
# include <ctime>
# include <stack>
# include <set>
# include <list>
# include <random>
# include <deque>
# include <functional>
# include <iomanip>
# include <sstream>
# include <fstream>
# include <complex>
# include <numeric>
# include <immintrin.h>
# include <cassert>
# include <array>
# include <tuple>
# include <unordered_set>
# include <unordered_map>

//#include<bits/stdc++.h>


#define LL long long
#define LD long double
#define pb push_back
#define mp make_pair
#define ss second
#define ff first
#define opt ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define _sz(x) (LL)x.size()
#define _all(x) x.begin(),x.end()
#define el '\n'
#define eb emplace_back

using namespace std;
const LL N = 1, INF = 1e18;
vector<vector<LL> > g, rg;
vector<LL> used;
set<LL> st, st1;
LL d;

void dfs(LL v, LL p, bool f)
{
    used[v]++;
    if(used[v] > 2)
    {
        //used[v]--;
        return;
    }
    st.insert(v);
    st1.insert(v);
    d = max(_sz(st), d);
    if(f)
    {
        for(auto it : rg[v])
            if(it != p)
                dfs(it, v, 0);
    }
    else
        for(auto it : g[v])
            if(it != p)
                dfs(it, v, 1);
    if(p == -1)
        return;
    else
        dfs(p, v, !f);
    st.erase(v);
    //used[v]--;
}

void solve() {
    LL n;
    string s;
    cin >> s;
    LL ans1 = 0, ans2 = 0;
    for(LL i = 0; i < _sz(s); i++) {
        ans1 = ans1 * 10 + (s[0] - '0');
        n = n * 10 + (s[i] - '0');
    }
    if(s[0] == '9')
    {
        for(LL i = 0; i < _sz(s)+1; i++)
            ans2 = ans2*10 + 1;
    }
    else
    {
        for(LL i = 0; i < _sz(s); i++)
            ans2 = ans2*10 + (s[0]-'0'+1);
    }
    if(ans1 <= n)
        cout << ans2 << el;
    else
        cout << ans1 << el;
}

int main()
{
    opt;
    LL q = 1;
    cin >> q;
    while(q--)
        solve();
    return 0;
}

Test details

Test 1

Group: 1, 2

Verdict:

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:

input
1000
735425311146082632
756615631808964686
466489470801941584
100417544394053220
...

correct output
777777777777777777
777777777777777777
555555555555555555
111111111111111111
555555555555555555
...

user output
777777777777777777
777777777777777777
444444444444444444
111111111111111111
44444444444444
...
Truncated