求数据
  • 板块灌水区
  • 楼主Let_Fly
  • 当前回复0
  • 已保存回复0
  • 发布时间2023/10/23 14:57
  • 上次更新2023/11/2 11:43:40
查看原帖
求数据
760859
Let_Fly楼主2023/10/23 14:57

求s组T3 hack数据

#include<bits/stdc++.h>
using namespace std;
#define int long long

const int N=1e5+5;

int n;//0 bt,1 sho,2 int,3 long
struct OP1{
    string nm;
    int num;
    vector<pair<string,string> > meb;
    int len; 
};

map<string,OP1> stru;
map<string,int> ll;
map<string,int> dx;
map<string,int> qd;
map<string,string> nmtotp;

int yd;
vector<pair<string,string> > all;

pair<string,string> brk(string jx){
    string head,res;
    for(auto v:jx){
        if(v=='.')break;
        head+=v;
    }
    res=jx.erase(0,head.size());
    if(res.size())res.erase(0,1);
    return {head,res};
}

bool ckjb(string tp){
    if(tp=="byte"||tp=="short"||tp=="int"||tp=="long")return 1;
    return 0;
}
void place(string tp,string qz,int &st){
    int lll=ll[tp];
    if(st%lll!=0){
        st=st-st%lll;
        st+=lll;
    }
    qd[qz]=st;
    st+=dx[tp];
}

int depin(string tp,string nm,string jx,string qz){
    string head,res;
    pair<string,string> as;
    as=brk(jx);
    head=as.first,res=as.second;
    int lsyd=qd[qz];
    // cout<<res<<'\n';
    if(head.size()){
        OP1 now=stru[tp];
        for(int i=0;i<now.meb.size();i++){
            place(now.meb[i].first,qz+'.'+now.meb[i].second,lsyd);
            if(now.meb[i].second==head){
                int zhi=depin(now.meb[i].first,now.meb[i].second,res,qz+'.'+now.meb[i].second);
                // cout<<zhi<<'\n';
                return zhi;
            } //return depin(now.meb[i].first,now.meb[i].second,res,qz+'.'+now.meb[i].second);
        }
    }else{
        int lll=ll[tp];
        if(lsyd%lll!=0){
            lsyd=lsyd-lsyd%lll;
            lsyd+=lll;
        }
        qd[qz]=lsyd;
        return lsyd;
    }
    return 0;
}

void find(int pos,string chuan,string tp){
    if(ckjb(tp)){
        int st=qd[chuan],len=dx[tp];
        if(st<=pos&&pos<=st+len){
            cout<<chuan<<'\n';
            return;
        }
        cout<<"ERR"<<'\n';
        return;
    }
    OP1 now=stru[tp];
    int lsyd=qd[chuan];
    for(int i=0;i<now.meb.size();i++){
        place(now.meb[i].first,chuan+'.'+now.meb[i].second,lsyd);
        if(pos<lsyd){
            find(pos,chuan+'.'+now.meb[i].second,now.meb[i].first);
            return;
        }
    }
}

signed main(){
    cin>>n;
    ll["byte"]=1,ll["short"]=2,ll["int"]=4,ll["long"]=8;
    dx["byte"]=1,dx["short"]=2,dx["int"]=4,dx["long"]=8;
    for(int i=1;i<=n;i++){
        int op;
        cin>>op;
        if(op==1){
            string nm;
            int k;
            cin>>nm;
            cin>>k;
            OP1 op1;
            op1.nm=nm;
            op1.num=k;
            int maxx=0,lsyd=0;
            for(int j=1;j<=k;j++){
                string tp;
                string nn;
                cin>>tp>>nn;
                nmtotp[nn]=tp;
                int lll=ll[tp];
                if(lsyd%lll!=0){
                    lsyd=lsyd-lsyd%lll;
                    lsyd+=lll;
                }
                lsyd+=dx[tp];
                maxx=max(maxx,lll);
                op1.meb.emplace_back(tp,nn);
            }
            ll[nm]=maxx;
            if(lsyd%maxx!=0){
                lsyd=lsyd-lsyd%maxx;
                lsyd+=maxx;
            }
            dx[nm]=lsyd;
            cout<<lsyd<<' '<<maxx<<'\n';
            op1.len=maxx;
            stru[nm]=op1;
        }else if(op==2){
            string tp;
            string nn;
            cin>>tp>>nn;
            int lll=ll[tp];
            if(yd%lll!=0){
                yd=yd-yd%lll;
                yd+=lll;
            }
            cout<<yd<<'\n';
            qd[nn]=yd;
            yd+=dx[tp];
            all.push_back({tp,nn});
            nmtotp[nn]=tp;
        }else if(op==3){
            string jx;
            cin>>jx;
            string head,res;
            pair<string,string> as;
            as=brk(jx);
            head=as.first,res=as.second;
            // cout<<res<<'\n';
            for(auto v:all){
                if(v.second==head){
                    if(res.size())cout<<depin(nmtotp[head],head,res,head)<<'\n';
                    else cout<<qd[head]<<'\n';
                }
            }
        }else{
            int pos;
            cin>>pos;
            bool flag=0;
            for(auto v:all){
                if(qd[v.second]+dx[v.first]>pos&&pos>=qd[v.second]){
                    find(pos,v.second,v.first);
                    flag=1;
                    break;
                }
            }
            if(!flag)cout<<"ERR"<<'\n';
        }
    }
    return 0;
}
2023/10/23 14:57
加载中...