Submission #856333

# Submission time Handle Problem Language Result Execution time Memory
856333 2023-10-03T07:06:27 Z Tenis0206 Present (RMI21_present) C++11
29 / 100
4000 ms 600 KB
#include <bits/stdc++.h>

using namespace std;

const int vmax = 100;

struct sir
{
    vector<int> st;
    bool fr[vmax + 5];
    int Max;
    sir()
    {
        Max = 0;
        memset(fr,false,sizeof(fr));
    }
};

sir get_next(sir s)
{
    for(int val=1;val<=s.Max+1;val++)
    {
        if((s.st.empty() || s.st.back()!=val) && !s.fr[val])
        {
            s.st.push_back(val);
            break;
        }
        if(!s.st.empty() && s.st.back()==val)
        {
            s.st.pop_back();
        }
    }
    sir rez;
    rez.st = s.st;
    if(rez.st.size())
    {
        rez.Max = rez.st.front();
    }
    for(auto it : rez.st)
    {
        rez.fr[it] = true;
    }
    for(int a=rez.Max;a>=1;a--)
    {
        for(int b=a-1;b>=1;b--)
        {
            if(!rez.fr[a] || !rez.fr[b])
            {
                continue;
            }
            rez.fr[__gcd(a,b)] = true;
        }
    }
    return rez;
}

void solve_test()
{
    int k;
    cin>>k;
    sir rez;
    for(int i=1;i<=k;i++)
    {
        rez = get_next(rez);
    }
    vector<int> r;
    for(int val=1;val<=vmax;val++)
    {
        if(rez.fr[val])
        {
            r.push_back(val);
        }
    }
    cout<<r.size()<<' ';
    for(auto it : r)
    {
        cout<<it<<' ';
    }
    cout<<'\n';
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    //freopen("nr.in","r",stdin);
    //freopen("nr.out","w",stdout);
    int t;
    cin>>t;
    for(int test=1;test<=t;test++)
    {
        solve_test();
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 596 KB Output is correct
2 Correct 1 ms 504 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 596 KB Output is correct
2 Correct 1 ms 504 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 2379 ms 432 KB Output is correct
8 Correct 3590 ms 432 KB Output is correct
9 Correct 2758 ms 436 KB Output is correct
10 Correct 3303 ms 436 KB Output is correct
11 Correct 1590 ms 432 KB Output is correct
12 Correct 3127 ms 428 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 596 KB Output is correct
2 Correct 1 ms 504 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 2379 ms 432 KB Output is correct
8 Correct 3590 ms 432 KB Output is correct
9 Correct 2758 ms 436 KB Output is correct
10 Correct 3303 ms 436 KB Output is correct
11 Correct 1590 ms 432 KB Output is correct
12 Correct 3127 ms 428 KB Output is correct
13 Execution timed out 4003 ms 600 KB Time limit exceeded
14 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 596 KB Output is correct
2 Correct 1 ms 504 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 2379 ms 432 KB Output is correct
8 Correct 3590 ms 432 KB Output is correct
9 Correct 2758 ms 436 KB Output is correct
10 Correct 3303 ms 436 KB Output is correct
11 Correct 1590 ms 432 KB Output is correct
12 Correct 3127 ms 428 KB Output is correct
13 Execution timed out 4003 ms 600 KB Time limit exceeded
14 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 596 KB Output is correct
2 Correct 1 ms 504 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 2379 ms 432 KB Output is correct
8 Correct 3590 ms 432 KB Output is correct
9 Correct 2758 ms 436 KB Output is correct
10 Correct 3303 ms 436 KB Output is correct
11 Correct 1590 ms 432 KB Output is correct
12 Correct 3127 ms 428 KB Output is correct
13 Execution timed out 4003 ms 600 KB Time limit exceeded
14 Halted 0 ms 0 KB -