提交记录 18626


用户 题目 状态 得分 用时 内存 语言 代码长度
02Ljh noip17b. 【NOIP2017】时间复杂度 Accepted 100 125 us 44 KB C++ 3.31 KB
提交时间 评测时间
2022-11-07 19:21:32 2022-11-07 19:21:43
#include <bits/stdc++.h>
using namespace std;
#define INF 0x3f3f3f3f
#define ll long long
#define E() puts("ERR");
#define Y() puts("Yes");
#define N() puts("No");
#define rt return ;
#define ll long long
vector <int> eq;
vector <int> fq;
vector <char> q;
unordered_map <char,bool> mapp;
unordered_map <char,bool> v;
string s[101];
struct lxy
{
    int np,va;
} temp;
int n,w,pf;
bool kd;
void init()
{
    eq.clear();
    fq.clear();
    mapp.clear();
    v.clear();
    q.clear();
    kd=true;//true->O(n) false->O(n~w)
    pf=0;
    return ;
}
lxy cl(int s,string t)
{
    //cout<<t.size()<<"sizeeeee\n";
    int lans=0,p=0;
    for(int i=s;i<t.size();i++)
    {
        if(!isdigit(t[i])) break;
        lans=lans*10+(int)(t[i]-'0');
        p=i;
    }
    temp.np=p;
    temp.va=lans;
    return temp;
}
void tqq()
{
    string tl;
    cin>>tl;
    //cout<<tl<<"\n";
    for(int i=0;i<tl.size();i++)
    {
        if(tl[i]=='O')
        {
            if(isdigit(tl[i+2]))
            {
                w=cl(i+2,tl).va;
            }
            else
            {
                w=cl(i+4,tl).va;
                kd=false;
            }
        }
    }
    return ;
}
bool flag;
int dg()
{
    int anss=0;
    char vp='=';
    for(int i=1;i<=n;i++)
    {
        //cout<<vp<<"\n";
        if(s[i][0]=='E')
        {
            if(q.empty()) { E(); return -1; }
            mapp[q.back()]=false;
            if(v[q.back()])
            {
                v[q.back()]=false;
                pf--;
            }
            if(vp==q.back()) vp='=';
            q.pop_back();
            //puts("");
        }
        if(s[i][0]=='F')
        {
            int st=-1,en=INF,ans=-1;
            if(mapp[s[i][2]]) { E(); return -1; }
            mapp[s[i][2]]=true;
            q.push_back(s[i][2]);
            int ne=4;
            //cout<<"wahwe="<<s[i][4]<<"\n";
            if(isdigit(s[i][4]))
            {
                //puts("FUCK");
                temp=cl(4,s[i]);
                ne=temp.np;
                st=temp.va;
            }
            else ans=114;
            if(ans==-1&&isdigit(s[i][ne+2])) { en=cl(ne+2,s[i]).va; ans=1; }
            //cout<<"NEEEE="<<ne<<" st="<<st<<" "<<ans<<"\n";
            if(ans==-1&&s[i][ne+2]=='n'&&s[i][ne]!='n'&&vp=='=')
            {
                v[s[i][2]]=true;
                //cout<<"AC="<<s[i][2]<<"\n";
                ans=-19;
                pf++;
                anss=max(pf,anss);
            }
            if(en<st||(ans==114&&s[i][ne+2]!='n')) vp=s[i][2];
            //mapp[s[i][2]]=false;
        }
    }
    return anss;
}
void work()
{
    cin>>n;
    tqq();
    //cout<<n<<"\n";
    getchar();
    for(int i=1;i<=n;i++)
    {
        //cin.clear();
        getline(cin,s[i]);
        //
        //cout<<s[i]<<"\n";
        if(s[i][0]=='E') eq.push_back(i);
        else if(s[i][0]=='F') fq.push_back(i);
    }
    //cout<<eq.size()<<"=="<<fq.size()<<"\n";
    if(eq.size()!=fq.size())
    {
        E();
        rt;
    }
    flag=true;
    int a_=dg();
    if(a_==-1) rt;
    //cout<<"a="<<a_<<" pf="<<pf<<"\n";
    if(a_==w) { Y(); rt; }
    if(w==1&&a_==0&&kd) { Y(); rt; }
    N();
    rt;
}
int main()
{
    //cout<<cl(6,"O(nlog4)");
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    int _;
    cin>>_;
    while(_--)
    {
        init();
        work();
    }
    return 0;
}

CompilationN/AN/ACompile OKScore: N/A

Testcase #148.74 us40 KBAcceptedScore: 10

Testcase #251.64 us40 KBAcceptedScore: 10

Testcase #362.47 us40 KBAcceptedScore: 10

Testcase #474.92 us44 KBAcceptedScore: 10

Testcase #574.76 us44 KBAcceptedScore: 10

Testcase #662.22 us44 KBAcceptedScore: 10

Testcase #794.31 us44 KBAcceptedScore: 10

Testcase #8125 us44 KBAcceptedScore: 10

Testcase #9112.31 us44 KBAcceptedScore: 10

Testcase #1094.09 us44 KBAcceptedScore: 10


Judge Duck Online | 评测鸭在线
Server Time: 2024-12-05 10:23:21 | Loaded in 1 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠