ENG  RUSTimus Online Judge
Online Judge
Задачи
Авторы
Соревнования
О системе
Часто задаваемые вопросы
Новости сайта
Форум
Ссылки
Архив задач
Отправить на проверку
Состояние проверки
Руководство
Регистрация
Исправить данные
Рейтинг авторов
Текущее соревнование
Расписание
Прошедшие соревнования
Правила
вернуться в форум

Обсуждение задачи 2061. OEIS A216264

Some Deductions on the Problem
Послано orzczt 3 апр 2016 12:54
If you search for the id "A216264" on oeis.org, you would find a table of a(n), n=1..60.
One interesting thing is that the site said that it was Mikhail Rubinchik who calculated a(26) to a(60), which happened to be out of the brute-force range. What is really disappointing is that in this problem, n may be 61, I think it's that guys's trick to play with us. Another interesting fact is that this guy also invented and introduced the Palindromic Tree. So, I deduce that the solution to this problem is somehow related to this data structure.

Edited by author 03.04.2016 12:56
Re: Some Deductions on the Problem
Послано Vit Demidenko 20 ноя 2018 17:16
Yes, with eertree you can bruteforce all answers
My solution runs ~20 hours to generate result, it can be theoretically speed up 2 times by bruteforcing only strings such s<=reverse(s)
Re: Some Deductions on the Problem
Послано Levon Oganesyan 3 мар 2020 03:05
How could you bruteforce 2^61 strings of length 61?
Re: Some Deductions on the Problem
Послано Virus TI 27 июн 2020 01:37
imagine a binary tree of these strings, use DFS with eertree
Re: Some Deductions on the Problem
Послано coder 27 авг 2023 17:49
https://iq.opengenus.org/palindromic-tree-eertree/

Use custom allocator with fixed 128 Node.

struct NodeAllocator
{
    Node nodes[128];
    int pos = 0;
    Node* allocate() {
        assert(pos < 128);
        return nodes + (pos++);
    }

};


std::uint64_t rich_number(std::uint64_t val, int pos, int n, EerTree& tree)
{
    if (pos >= n) return 1;
    std::int64_t res = 0;
    for (std::uint64_t bit = 0; bit < 2; ++bit)
    {
        std::uint64_t s = val | (bit << pos);
        /********************************************/
        Node* t_current = tree.current;
        int t_pos = tree.alloc.pos;
        /********************************************/

        int r = tree.insert(s, pos);

        /********************************************/
        Node* cur_change = tree.cur_change;
        /********************************************/

        if (r == 1) {
            res += rich_number(s, pos + 1, n, tree);
        }


        /********************************************/
        //reset tree insert back
        tree.current = t_current;
        tree.alloc.pos = t_pos;
        if (r==1){
            cur_change->labeled[bit] = nullptr;
        }
        /********************************************/
    }

    return res;
}

------------
rich_number(0, 0, 61) -> gives  61-rich palindrome.


My computer it runs 52 hours.
Re: Some Deductions on the Problem
Послано Resert 22 ноя 2023 03:09
Это да, супер


Edited by author 22.11.2023 03:10