当前位置: 首页>>代码示例>>C++>>正文


C++ trie::parse_input方法代码示例

本文整理汇总了C++中trie::parse_input方法的典型用法代码示例。如果您正苦于以下问题:C++ trie::parse_input方法的具体用法?C++ trie::parse_input怎么用?C++ trie::parse_input使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在trie的用法示例。


在下文中一共展示了trie::parse_input方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main()
{
	cout<<"KOAKSODKASdokasdo\n";
	
    _trie = trie();

    for (int i = 0; i < 500100; i++)
        finished [i] = turns_into [i] = -1;

    scanf ("%d", &n); getchar();
    for (int i = 0; i < n; i++)
        _trie.parse_input();

    for (int i = 0; i < words.size(); i++)
        printf ("%d ", words [i]); printf ("\n");


    scanf ("%d", &m); getchar();

    for (int i = 0; i < m; i++)
    {
        int X = _trie.parse_input();
        int Y = _trie.parse_input();

        printf ("%d %d\n", X, Y);
        turns_into[X] = Y;
        cool [X] = true;

        QMAX = max (X, Y);
    }

    QMAX = max (QMAX, word_index);

    int R = 0, L = 0;

    for (int i = 0; i < words.size(); i)
    {
        if (turns_into [words [i]] == -1)
        {
            R += R_count [words [i]];
            L += lengths [words [i]];
        }
        else if (finished [words [i]])
        {
            R += R_count [words [i]];
            L += lengths [words [i]];
        }
        else
        {
            stacks.clear();
            int current_index = words [i];
            int q = i - 1;

            while (finished [current_index] != -1)
            {
                stacks.push_back(current_index);
                finished[current_index] = 1;
                current_index = turns_into [current_index];
            }
            stacks.push_back(current_index);

            int MAXR = R_count[current_index];
            int MAXL = lengths[current_index];

            for (int j = stacks.size() - 2; j > -1; j--)
            {
                if (R_count [stacks [j]] == R_count [stacks [j - 1]])
                {
                    R_count[stacks [j]] = R_count[stacks [j + 1]];
                }
            }
        }
    }

    return 0;
}
开发者ID:elvircrn,项目名称:ccppcodes,代码行数:76,代码来源:D+(15).cpp


注:本文中的trie::parse_input方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。