{"id":292,"date":"2018-10-31T19:53:17","date_gmt":"2018-10-31T11:53:17","guid":{"rendered":"http:\/\/SmokeyDays.top\/wordpress\/?p=292"},"modified":"2018-11-07T16:35:18","modified_gmt":"2018-11-07T08:35:18","slug":"lp3952-noip2018-%e6%97%b6%e9%97%b4%e5%a4%8d%e6%9d%82%e5%ba%a6","status":"publish","type":"post","link":"http:\/\/SmokeyDays.top\/wordpress\/2018\/10\/31\/lp3952-noip2018-%e6%97%b6%e9%97%b4%e5%a4%8d%e6%9d%82%e5%ba%a6\/","title":{"rendered":"lp3952 NOIP2017 \u65f6\u95f4\u590d\u6742\u5ea6"},"content":{"rendered":"<p>\u9b54\u9b3c\u7684\u5927\u529b\u6a21\u62df\u9898\u3002<br \/>\n\u5343\u4e07\u8981\u6ce8\u610f\u5927\u5c0f\u5199\u3002<br \/>\n\u6ce8\u610f\u6570\u5b57\u3001\u5b57\u7b26\u4e32\u8f6c\u5316\u3002\u8fd9\u4e2a\u7ec6\u8282\u56f0\u6270\u4e86\u6211\u5f88\u4e45\u3002<\/p>\n<pre class=\"pure-highlightjs\"><code class=\"cpp\">#include&lt;iostream&gt;\r\n#include&lt;cstdio&gt;\r\n#include&lt;cstring&gt;\r\nusing namespace std;\r\n\r\n#define Max(_A,_B) ((_A)&gt;(_B)?(_A):(_B))\r\nbool usd[30];\r\n\/\/lv==-1:\u8fd9\u5c42\u5faa\u73af\u6839\u672c\u4e0d\u4f1a\u88ab\u6267\u884c\u3002 \r\nstruct data{\r\n    int lv;\r\n    int x;\r\n}st[105];\r\nint tp=0,n,slv=0,nlv=0,ans=0;\r\nchar ch[105];\r\ninline int cg(){\r\n    int _X=0,_BS=10,i=0;\r\n    while(ch[i]&lt;'0'||ch[i]&gt;'9'){\r\n        ++i;\r\n    }\r\n    while(ch[i]&gt;='0'&amp;&amp;ch[i]&lt;='9'){\r\n        _X*=_BS;\r\n        _X+=((ch[i]-'0'));\r\n        ++i;\r\n    }\r\n    return _X;\r\n}\r\nvoid init(){\r\n    scanf(\"%d\",&amp;n);\r\n    memset(usd,0,sizeof(usd));\r\n    tp=0,nlv=0;\r\n    int ss,tt;\r\n    cin&gt;&gt;ch;\r\n    if(ch[2]=='1'){\r\n        slv=0;\r\n    }else{\r\n        slv=cg();\r\n    }\r\n    st[0].lv=0;\r\n    st[0].x=-1;\r\n    bool bo=0; \r\n    for(int i=1;i&lt;=n;++i){\r\n        cin&gt;&gt;ch;\r\n        if(ch[0]=='E'){\r\n            if(!tp){\r\n                bo=1;\r\n            }else{\r\n                nlv=Max(nlv,st[tp].lv);\r\n                usd[st[tp].x]=0;\r\n                --tp;\r\n            }\r\n        }else{\r\n            cin&gt;&gt;ch;\r\n            ++tp;\r\n            if(usd[ch[0]-'a']){\r\n                bo=1;\r\n            }else{\r\n                usd[ch[0]-'a']=1;\r\n                st[tp].x=ch[0]-'a';\r\n            }\r\n            memset(ch,0,sizeof(ch));\r\n            cin&gt;&gt;ch;\r\n            if(ch[0]=='n'){\r\n                ss=100000;\r\n            }else{\r\n                ss=cg();\r\n            }\r\n            memset(ch,0,sizeof(ch));\r\n            cin&gt;&gt;ch;\r\n            if(ch[0]=='n'){\r\n                tt=100000;\r\n            }else{\r\n                tt=cg();\r\n            }\r\n            memset(ch,0,sizeof(ch));\r\n            if(st[tp-1].lv==-1){\r\n                st[tp].lv=-1;\r\n                continue;\r\n            }\r\n            if(ss&gt;tt){\r\n                st[tp].lv=-1;\r\n            }else if(ss==tt||(tt!=100000)){\r\n                st[tp].lv=st[tp-1].lv;\r\n            }else if(tt==100000){\r\n                st[tp].lv=st[tp-1].lv+1;\r\n            }\r\n        }\r\n    }\r\n    if(tp||bo){\r\n        puts(\"ERR\");\r\n        return;\r\n    }\r\n    if(nlv==slv){\r\n        puts(\"Yes\");\r\n    }else{\r\n        puts(\"No\");\r\n    }\r\n}\r\nint main(){\r\n    int T;\r\n    scanf(\"%d\",&amp;T);\r\n    while(T--){\r\n        init();\r\n    }\r\n    return 0;\r\n}<\/code><\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u9b54\u9b3c\u7684\u5927\u529b\u6a21\u62df\u9898\u3002 \u5343\u4e07\u8981\u6ce8\u610f\u5927\u5c0f\u5199\u3002 \u6ce8\u610f\u6570\u5b57\u3001\u5b57\u7b26\u4e32\u8f6c\u5316\u3002\u8fd9\u4e2a\u7ec6\u8282\u56f0\u6270\u4e86\u6211\u5f88\u4e45\u3002 #include&lt; &hellip; <\/p>\n<p class=\"link-more\"><a href=\"http:\/\/SmokeyDays.top\/wordpress\/2018\/10\/31\/lp3952-noip2018-%e6%97%b6%e9%97%b4%e5%a4%8d%e6%9d%82%e5%ba%a6\/\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">\u201clp3952 NOIP2017 \u65f6\u95f4\u590d\u6742\u5ea6\u201d<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[10,25,8,6,5],"tags":[],"_links":{"self":[{"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/posts\/292"}],"collection":[{"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/comments?post=292"}],"version-history":[{"count":4,"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/posts\/292\/revisions"}],"predecessor-version":[{"id":363,"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/posts\/292\/revisions\/363"}],"wp:attachment":[{"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/media?parent=292"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/categories?post=292"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/tags?post=292"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}