Submission #642937

#TimeUsernameProblemLanguageResultExecution timeMemory
642937danikoynovPresent (RMI21_present)C++14
29 / 100
1176 ms269080 KiB
/**
 ____ ____ ____ ____ ____ ____
||l |||e |||i |||n |||a |||d ||
||__|||__|||__|||__|||__|||__||
|/__\|/__\|/__\|/__\|/__\|/__\|

**/

#include<bits/stdc++.h>
#define endl '\n'

using namespace std;
typedef long long ll;

void speed()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

const ll maxn = 1e6 + 10, maxnum = 150;
vector < vector < ll > > st;
ll gcd[maxnum][maxnum];
void preprocess()
{
    for (ll i = 1; i < maxnum; i ++)
        for (ll j = 1; j < maxnum; j ++)
            gcd[i][j] = __gcd(i, j);
    ll mask = 0;
    while(st.size() < maxn)
    {
        vector < ll > num;
        for (ll bit = 0; (1 << bit) <= mask; bit ++)
            if ((mask & (1 << bit)))
                num.push_back(bit + 1);

        bool tf = true;
        ll atl = 0;
        for (ll i = 0; i < num.size() && tf; i ++)
            for (ll j = i + 1; j < num.size(); j ++)
            {
                ll x = gcd[num[i]][num[j]];
                if ((mask & (1 << (x - 1))) == 0)
                {
                    atl = x;
                    tf = false;
                    break;
                }
            }

        if (tf)
        {
            st.push_back(num);
            mask ++;
        }
        else
            mask = (mask | (1 << (atl - 1)));

    }
    ///cout << "Done " << mask << endl;
    //exit(0);
}

void solve()
{
    ll n;
    cin >> n;
    cout << st[n].size();
    for (ll v : st[n])
        cout << " " << v;
    cout << endl;

}

int main()
{
    preprocess();
    ll t;
    cin >> t;
    while(t --)
        solve();
    return 0;
}

Compilation message (stderr)

Main.cpp: In function 'void preprocess()':
Main.cpp:40:26: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |         for (ll i = 0; i < num.size() && tf; i ++)
      |                        ~~^~~~~~~~~~~~
Main.cpp:41:34: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |             for (ll j = i + 1; j < num.size(); j ++)
      |                                ~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...