首页 > 其他分享 >T3 ! 我!改!出!来!了!

T3 ! 我!改!出!来!了!

时间:2024-10-04 17:11:05浏览次数:5  
标签:wlx ln T3 else wudi && rn

你说得对,但是我 15k 分讨改出来了!

#include<bits/stdc++.h>
#define fo(x, y, z) for(register int (x) = (y); (x) <= (z); (x)++)
#define fu(x, y, z) for(register int (x) = (y); (x) >= (z); (x)--)
using namespace std;
typedef long long ll;
#define lx ll
inline lx qr()
{
	char ch = getchar();lx x = 0 , f = 1;
	for(;ch<'0'||ch>'9';ch = getchar()) if(ch == '-') f = -1;
	for(;ch>= '0' && ch<= '9';ch = getchar()) x = (x<<3) + (x<<1) + (ch^48);
	return x*f;
}
#undef lx
#define qr qr()
#define pii pair<int , int>
#define fi first
#define se second
const int Ratio = 0;
const int N = 2e5 + 5, x = 1e9;
const int mod = 1e9 + 7;
int n, m;
string s;
int a[N];
struct rmm
{
    int llx, rlx, wlx;
    int ln, rn;
    bool wudi;
    rmm(){llx = rlx = wlx = ln = rn = 0; wudi = 0;}
} t[N << 2];
namespace Wisadel
{
    int W(char c)
    {
        if(c == 'R') return 1;
        else if(c == 'S') return 2;
        else return 3;
    }
    char M(int x)
    {
        if(x == 1) return 'R';
        else if(x == 2) return 'S';
        else return 'P';
    }
    int Wpk(int aa, int bb)
    {
        if(!aa || !bb) return aa + bb;
        if(aa == bb) return aa;
        if(((aa == 1 || aa == 2) && bb == aa + 1) || (aa == 3 && bb == 1) ) return aa;
        return bb;
    }
    #define ls (rt << 1)
    #define rs (rt << 1 | 1)
    #define mid ((l + r) >> 1)
    rmm Wpushup(rmm a, rmm b)
    {
        rmm c;
        c.llx = a.llx, c.rlx = b.rlx;
        c.ln = c.rn = 0;
        c.wudi = 0;
        int wn = Wpk(a.rlx, b.llx);
        if(a.wudi && b.wudi)
        {
            if(a.rlx != b.llx)
            {
                if(wn == a.rlx)//
                {
                    if(a.ln + 1 > b.rn)
                    {
                        c.wlx = a.wlx;
                        c.rn = a.rn, c.ln = a.ln + 1 - b.rn + b.ln;
                    }
                    else
                    {
                        c.wlx = b.wlx;
                        c.ln = b.ln, c.rn = b.rn - 1 - a.ln + a.rn;
                    }
                }
                else
                {
                    if(a.ln > b.rn + 1)
                    {
                        c.wlx = a.wlx;
                        c.rn = a.rn, c.ln = a.ln - 1 - b.rn + b.ln;
                    }
                    else
                    {
                        c.wlx = b.wlx;
                        c.ln = b.ln, c.rn = b.rn + 1 - a.ln + a.rn;
                    }
                }
            }
            else
            {
                if(a.ln > b.rn)
                {
                    c.wlx = a.wlx;
                    c.rn = a.rn, c.ln = a.ln - b.rn + b.ln;
                }
                else
                {
                    c.wlx = b.wlx;
                    c.ln = b.ln, c.rn = b.rn - a.ln + a.rn;
                }
            }
            c.wudi = 1;
            return c;
        }
        if(a.wudi)
        {
            if(a.rlx != b.llx)
            {
                if(wn == a.rlx)
                {
                    if(b.ln)
                    {
                        c.wlx = a.wlx;
                        c.rn = a.rn, c.ln = a.ln + b.ln + 1;
                        c.wudi = 1;
                    }
                    else if(b.rn)
                    {
                        if(a.ln + 1 > b.rn)
                        {
                            c.wlx = a.wlx;
                            c.rn = a.rn, c.ln = a.ln + 1 - b.rn;
                            c.wudi = 1;
                        }
                        else
                        {
                            c.wlx = b.wlx;
                            c.rn = b.rn - a.ln - 1 + a.rn;
                        }
                    }
                    else
                    {
                        c.wlx = a.wlx;
                        c.rn = a.rn, c.ln = a.ln + 1;
                        c.wudi = 1;
                    }
                }
                else
                {
                    if(b.ln)
                    {
                        c.wlx = a.wlx;
                        c.rn = a.rn, c.ln = a.ln + b.ln - 1;
                        c.wudi = 1;
                    }
                    else if(b.rn)
                    {
                        if(a.ln - 1 > b.rn)
                        {
                            c.wlx = a.wlx;
                            c.rn = a.rn, c.ln = a.ln - 1 - b.rn;
                            c.wudi = 1;
                        }
                        else
                        {
                            c.wlx = b.wlx;
                            c.rn = b.rn - a.ln + 1 + a.rn;
                        }
                    }
                    else
                    {
                        c.wlx = a.wlx;
                        c.rn = a.rn;
                        if(a.ln > 1)
                        {
                            c.ln = a.ln - 1;
                            c.wudi = 1;
                        }
                    }
                }
            }
            else
            {
                if(b.ln)
                {
                    c.wlx = a.wlx;
                    c.rn = a.rn, c.ln = a.ln + b.ln;
                    c.wudi = 1;
                }
                else if(b.rn)
                {
                    if(a.ln > b.rn)
                    {
                        c.wlx = a.wlx;
                        c.rn = a.rn, c.ln = a.ln - b.rn;
                        c.wudi = 1;
                    }
                    else
                    {
                        c.wlx = b.wlx;
                        c.rn = b.rn - a.ln + a.rn;
                    }
                }
                else
                {
                    c.wlx = a.wlx;
                    c.ln = a.ln, c.rn = a.rn;
                    c.wudi = 1;
                }
            }
            return c;
        }
        if(b.wudi)
        {
            if(a.rlx != b.llx)
            {
                if(wn == b.llx)
                {
                    if(a.rn)
                    {
                        c.wlx = b.wlx;
                        c.ln = b.ln, c.rn = b.rn + 1 + a.rn;
                        c.wudi = 1;
                    }
                    else if(a.ln)
                    {
                        if(b.rn + 1 > a.ln)
                        {
                            c.wlx = b.wlx;
                            c.ln = b.ln, c.rn = b.rn + 1 - a.ln;
                            c.wudi = 1;
                        }
                        else
                        {
                            c.wlx = a.wlx;
                            c.ln = a.ln - 1 - b.rn + b.ln;
                        }
                    }
                    else
                    {
                        c.wlx = b.wlx;
                        c.ln = b.ln, c.rn = b.rn + 1;
                        c.wudi = 1;
                    }
                }
                else
                {
                    if(a.rn)
                    {
                        c.wlx = b.wlx;
                        c.ln = b.ln, c.rn = b.rn - 1 + a.rn;
                        c.wudi = 1;
                    }
                    else if(a.ln)
                    {
                        if(b.rn - 1 > a.ln)
                        {
                            c.wlx = b.wlx;
                            c.ln = b.ln, c.rn = b.rn - 1 - a.ln;
                            c.wudi = 1;
                        }
                        else
                        {
                            c.wlx = a.wlx;
                            c.ln = a.ln + 1 - b.rn + b.ln;
                        }
                    }
                    else
                    {
                        c.wlx = b.wlx;
                        c.ln = b.ln;
                        if(b.rn > 1)
                        {
                            c.rn = b.rn - 1;
                            c.wudi = 1;
                        }
                    }
                }
            }
            else
            {
                if(a.rn)
                {
                    c.wlx = b.wlx;
                    c.ln = b.ln, c.rn = b.rn + a.rn;
                    c.wudi = 1;
                }
                else if(a.ln)
                {
                    if(b.rn > a.ln)
                    {
                        c.wlx = b.wlx;
                        c.ln = b.ln, c.rn = b.rn - a.ln;
                        c.wudi = 1;
                    }
                    else
                    {
                        c.wlx = a.wlx;
                        c.ln = a.ln - b.rn + b.ln;
                    }
                }
                else
                {
                    c.wlx = b.wlx;
                    c.ln = b.ln, c.rn = b.rn;
                    c.wudi = 1;
                }
            }
            return c;
        }
        //
        if(a.rlx != b.llx)
        {
            if(wn == a.rlx)// 
            {
                if((a.ln && b.ln) || (!a.ln && !a.rn && b.ln) || (a.ln && !b.ln && !b.rn))
                {
                    c.wlx = a.wlx;
                    c.ln = a.ln + b.ln + 1;
                }
                else if(a.ln && b.rn)
                {
                    if(a.ln > b.rn - 1)
                    {
                        c.wlx = a.wlx;
                        c.ln = a.ln - b.rn + 1;
                    }
                    else
                    {
                        c.wlx = b.wlx;
                        c.rn = b.rn - 1 - a.ln;
                    }
                }
                else if((a.rn && b.ln) || (a.rn && !b.ln && !b.rn))
                {
                    c.wlx = a.wlx;
                    c.ln = b.ln + 1;
                    c.rn = a.rn;
                    c.wudi = 1;
                }
                else if(a.rn && b.rn)
                {
                    c.wlx = b.wlx;
                    c.rn = a.rn + b.rn - 1;
                }
                else if(!a.ln && !a.rn && !b.ln && !b.rn)
                {
                    c.wlx = a.wlx;
                    c.ln = 1;
                }
                else if(!a.ln && !a.rn && b.rn)
                {
                    c.wlx = b.wlx;
                    c.rn = b.rn - 1;
                }
            }
            if(wn == b.llx)// ←
            {
                // cout<<"BUOK!"<<endl;
                if((a.rn && b.rn) || (!a.ln && !a.rn && b.rn) || (a.rn && !b.ln && !b.rn))
                {
                    c.wlx = b.wlx;
                    c.rn = a.rn + b.rn + 1;
                }
                else if(a.ln && b.rn)
                {
                    if(b.rn > a.ln - 1)
                    {
                        c.wlx = b.wlx;
                        c.rn = b.rn - a.ln + 1;
                    }
                    else
                    {
                        c.wlx = a.wlx;
                        c.ln = a.ln - 1 - b.rn;
                    }
                }
                else if((a.rn && b.ln) || (b.ln && !a.ln && !a.rn))
                {
                    c.wlx = b.wlx;
                    c.ln = b.ln;
                    c.rn = a.rn + 1;
                    c.wudi = 1;
                }
                else if(a.ln && b.ln)
                {
                    c.wlx = a.wlx;
                    c.ln = a.ln + b.ln - 1;
                }
                else if(!a.ln && !a.rn && !b.ln && !b.rn)
                {
                    c.wlx = b.wlx;
                    c.rn = 1;
                }
                else if(a.ln && !b.ln && !b.rn)
                {
                    // cout<<"BUOK!"<<endl;
                    c.wlx = a.wlx;
                    c.ln = a.ln - 1;
                }
            }
        }
        else
        {
            if((a.ln && b.ln) || (!a.ln && !a.rn && b.ln) || (a.ln && !b.ln && !b.rn))
            {
                c.wlx = a.wlx;
                c.ln = a.ln + b.ln;
            }
            else if((a.ln && b.rn))
            {
                if(a.ln > b.rn)
                {
                    c.wlx = a.wlx;
                    c.ln = a.ln - b.rn;
                }
                else
                {
                    c.wlx = b.wlx;
                    c.rn = b.rn - a.ln;
                }
            }
            else if(a.rn && b.ln)
            {
                c.wlx = a.wlx;
                c.rn = a.rn, c.ln = b.ln;
                c.wudi = 1;
            }
            else if((a.rn && b.rn) || (!a.ln && !a.rn && b.rn) || (a.rn && !b.ln && !b.rn))
            {
                c.wlx = b.wlx;
                c.rn = a.rn + b.rn;
            }
            else if(!a.ln && !a.rn && !b.ln && !b.rn)
            {
                c.wlx = a.wlx;
            }
        }
        return c;
    }
    void Wbuild(int rt, int l, int r)
    {
        if(l == r)
        {
            t[rt].llx = t[rt].rlx = t[rt].wlx = a[l];
            t[rt].ln = t[rt].rn = 0;
            return;
        }
        Wbuild(ls, l, mid), Wbuild(rs, mid + 1, r);
        t[rt] = Wpushup(t[ls], t[rs]);
        // cout<<l<<' '<<r<<' '<<t[rt].ln<<' '<<t[rt].rn<<' '<<t[rt].wlx<<' '<<t[rt].wudi<<endl;
    }
    void Wupd(int rt, int l, int r, int x, int k)
    {
        if(l == r)
        {
            t[rt].llx = t[rt].rlx = t[rt].wlx = k;
            t[rt].ln = t[rt].rn = 0;
            return;
        }
        if(x <= mid) Wupd(ls, l, mid, x, k);
        else Wupd(rs, mid + 1, r, x, k);
        t[rt] = Wpushup(t[ls], t[rs]);
    }
    rmm Wq(int rt, int l, int r, int x, int y)
    {
        if(x <= l && r <= y) return t[rt];
        rmm lans, rans; int ly = 0, ry = 0;
        if(x <= mid) lans = Wq(ls, l, mid, x, y), ly = 1;
        if(y > mid) rans = Wq(rs, mid + 1, r, x, y), ry = 1;
        if(ly && ry)
        {
            // cout<<l<<' '<<mid<<' '<<r<<endl;
            // cout<<lans.ln<<' '<<lans.rn<<' '<<lans.wlx<<' '<<lans.wudi<<endl;
            // cout<<rans.ln<<' '<<rans.rn<<' '<<rans.wlx<<' '<<rans.wudi<<endl;
            // cout<<endl;
            return Wpushup(lans, rans);
        }
        else if(ly) return lans;
        else return rans;
    }
    short main()
    {
        // freopen(".in", "r", stdin) , freopen(".out", "w", stdout);
        freopen("a.in", "r", stdin) , freopen("a.out", "w", stdout);
        n = qr, m = qr;
        cin>>s;
        fo(i, 0, n - 1) a[i + 1] = W(s[i]);
        Wbuild(1, 1, n);
        fo(i, 1, m)
        {
            int op = qr, l = qr, r; char ch;
            if(op == 1)
            {
                scanf(" %c", &ch);
                Wupd(1, 1, n, l, W(ch));
            }
            else
            {
                r = qr;
                // fo(j, l, r)
                // {
                //     cout<<M(Wq(1, 1, n, j, j).wlx);
                // }
                // cout<<endl;
                rmm zc = Wq(1, 1, n, l, r);
                // cout<<zc.ln<<' '<<zc.rn<<' '<<zc.llx<<' '<<zc.rlx<<' ';
                printf("%c\n", M(zc.wlx));
            }
        }
        return Ratio;
    }
}
int main(){return Wisadel::main();}

标签:wlx,ln,T3,else,wudi,&&,rn
From: https://www.cnblogs.com/Ratio-Yinyue1007/p/18446872

相关文章

  • 关于AT32A403A烧录程序时不启动的问题
    具体描述:第1块板是一边写代码一边烧录测试,一直没什么异常,整片擦除,再烧录,功能一切正常。之后就又焊了两块板,把程序烧录进去之后芯片没反应。进入仿真模式会卡在startup_at32f403a_407.s的151行LDRR0,=SystemInit后面发现一个奇怪的解决办法,就把程序大部分代码注释掉......
  • micropython +ESP32+ sht30 温湿度模块
    SHT30  1)查找SHT30芯片资料  https://www.szlcsc.com2)根据芯片资料,查得   地址为0x44或0x45    选 MeasurementCommandsforSingleShotDataAcquisitionMode,命令为 0x2c103)连线 SHT30      ESP32     D1(SCL)    4......
  • YOKOGAWA横河WT310(E)功率计使用说明
    一、基本页面介绍下面是功率计右上角指示灯的含义二、显示的字符串及对应的含义显示采用7段码进行显示,具体表现形式参考下图对于显示区域A中代表的含义三、按键定义及作用FUNCTION:每按下一次FUNCTION,都会进行显示功能的切换。四个显示页面能够显示的数据不完全一......
  • 【MX-J3-T3+】Tuple+ 题解
    一个比较自然的思路就是对于每个三元组\((u_i,v_i,w_i)\),把\((v_i,w_i)\)这个二元组放在属于\(u_i\)的vector里面。然后对于每一个\(i\in[1,n-3]\),把\(i\)的vector里面的所有二元组\((x,y)\)当作一条连接\(x,y\)的无向边,则我们的目的是在图中找出所有的三元环\(......
  • 数据挖掘与机器学习(DM&ML)(PART3)
    三.DATA(Whatisdata?)1.1数据集的类型:记录型:数据矩阵:以矩阵形式呈现的数据集合,通常行代表对象(记录、实例等),列代表属性。例如,一个包含学生信息的数据集,行可以是不同的学生,列可以是学生的姓名、年龄、成绩等属性。文档数据:由文档组成的数据集,每个文档可以是一篇文章、一......
  • SpringBoot3自定义favicon.ico图标
            在学习SpringBoot项目的过程中,我想在我的个人项目中添加自定义favicon.ico的图标。但是你会发现在使用yml去配置favicon时,发现配置被废除了。如下图所示:        即使没有配置,SpringBoot也会帮我们去扫描resource包下的static,我们只需要将favicon.ico......
  • 对oceans_of_stars的T3爆标做法的基础结论的证明
    我们要证明的结论如下:\(x\)在\([1,x-1]\)中选取父亲,以这种方法构造树,节点\(x\)在其子树大小为\(i\)时的方案数为\(\binom{n-i-1}{x-2}\)。对于组合数有一个众所周知的结论:\[C_n^m=C_n^{n-m}\]然后把上面的选式转化一下,得到:\(\binom{n-i-1}{n-i-x+1}\)。还是组合数......
  • windows server 怎么 禁用 SWEET32 密码组
    在WindowsServer上禁用SWEET32密码组可以按照以下步骤进行操作:一、确定使用的加密协议首先,确定你的WindowsServer正在使用的加密协议是SSL/TLS还是其他协议。如果是SSL/TLS,通常是通过InternetInformationServices(IIS)或其他网络服务来实现的。二、使用注册......
  • 优化Windows 10 Direct3D性能的注册表;优化Direct3D和整体游戏性能,可以从图形渲染、GPU
    优化Windows10Direct3D性能的注册表.reg文件示例CopyCodeWindowsRegistryEditorVersion5.00;优化Direct3D性能[HKEY_CURRENT_USER\Software\Microsoft\Direct3D]"DisableDirectDraw"=dword:00000001"MaxTextureWidth"=dword:00000400"MaxText......
  • FIT3158 Business Decision Modelling
    MonashUniversityFacultyofInformationTechnology2ndSemester2024FIT3158BusinessDecisionModellingAssignment2:LinearProgramming,IntegerLinearProgramming,NetworkAnalysis,Transportation,TransshipmentandEconomicOrderQuantity(EOQ)-us......