zoukankan      html  css  js  c++  java
  • 让我自闭了两个星期的题 Hello xtCpc

    在比赛的时候这题卡了我们队3个小时,最后还是没过,放掉的时候依然不舍,始终找不到错解,比赛结束后回来自闭了2个星期,回来知道题目的解题时和自己当初解题的时候思路时一样的,只不过自己没有冷静下来把思路理的条例有序,导致当时wa了9次,直接搞崩心态。做题得一步一步来,绝不能有半点糊涂!一旦有糊涂,就找不到bug了,bug就藏在阴暗的角落,思维的盲点。让你难受。这题,我可能会记很久很久吧。

    ac代码:

    #include<iostream>
    #include<cstring>
    #include<queue>
    #include<cstdio>
    using namespace std;
    int main()
    {
        int n;
        while(~scanf("%d",&n))
        {
            char a;
            int ans=0,maxn=200010;
            queue<int> x;
            queue<int> t;
            queue<int> C;
            queue<int> p;
            queue<int> c;
            getchar();
            for(int i=0;i<n;i++)
            {
                scanf("%c",&a);
                if(a=='x')
                    x.push(i);
                else if(a=='t')
                    t.push(i);
                else if(a=='C')
                    C.push(i);
                else if(a=='p')
                    p.push(i);
                else if(a=='c')
                    c.push(i);
            }
            while(!x.empty()&&!t.empty()&&!C.empty()&&!p.empty()&&!c.empty())
            {
                int xx=x.front();
                int tt=t.front();
                int CC=C.front();
                int pp=p.front();
                int cc=c.front();
                while(tt<xx)
                {
                    t.pop();
                    if(t.empty())
                        tt=maxn;
                    else
                        tt=t.front();
                }
                while(CC<tt)
                {
                    C.pop();
                    if(C.empty())
                        CC=maxn;
                    else
                        CC=C.front();
                }
                while(pp<CC)
                {
                    p.pop();
                    if(p.empty())
                        pp=maxn;
                    else
                        pp=p.front();
                }
                while(cc<pp)
                {
                    c.pop();
                    if(c.empty())
                        cc=maxn;
                    else
                        cc=c.front();
                }
        //        cout<<xx<<" "<<tt<<" "<<CC<<" "<<pp<<" "<<cc<<endl;
                if(!x.empty()&&!t.empty()&&!C.empty()&&!p.empty()&&!c.empty())
                {
                    ans++;
                    x.pop();t.pop();C.pop();p.pop();c.pop();
                }
            }
            printf("%d
    ",ans);
        }
        return 0;
    }
  • 相关阅读:
    学习九-python 异常处理
    验证基于逻辑回归的隐马尔可夫模型的心音信号切分算法(literature study)
    字典的内置方法比较
    学习六
    Ubuntu 16.04 LTS 搜狗输入法安装
    集合经验模态分解(EEMD)在语音中的应用举例
    SwfUpload及imgareaselect使用方法
    Uploadify插件使用方法
    Ueditor使用方法
    PartialView 加载Js
  • 原文地址:https://www.cnblogs.com/wwq-19990526/p/10940208.html
Copyright © 2011-2022 走看看