1108 模拟赛

写在前面

今天的这场比赛。。。是可写的傻哭.jpgide

仍是我太菜了测试

T1走步(travel)

连接idea

Idea

这是一道数学题spa

前置芝士:余弦定理code

0.jpg

如图,点\(\mathcal A\)是走了\(n\)步所到达的点,到原点距离为\(x\)。(红线)blog

接下来走一步走到点\(\mathcal B\)\(\mathcal B\)\(\odot A\)上一点且\(r_A=1\),),设其到原点距离\(\mathcal {BO}=y\),(蓝线)ci

在$ \bigtriangleup OAB$中,使用余弦定理,得:
\[ y^2=x^2+1-2x \cos \theta \]
咱们发现\(\cos \theta\)的指望为零。。。(这一点但愿读者本身思考get

因此,式子化简成
\[ y^2=x^2+1 \]
由于咱们求的正是\(E(\mathcal D^2)\),咱们上面提到,\(\mathcal A\)是第\(n\)步走到的点,\(\mathcal B\)是第\(n+1\)步走到的点,那么\(f_{n+1}^2=f_n^2+1,n \ge 1\),因此第\(n\)步时,\(E(\mathcal D^2)=n\)数学

因此,输出\(n\)便可。class

另注:本题只有一个测试点卖萌.jpg

Code

namespace Sol{
    inline int Main(){
        put(read());//不解释,嘻嘻
        return 0;
    }
}

T2高不可攀

连接

Idea

对于本题,分块、莫队均可以写。代码等我回来再贴傻笑.png

这里说一种不严格的\(\mathcal O(n^2 \log n)\)

由于使用了二分,还加了些剪枝,因而卡过了数据。具体能够看代码。

Code

namespace Sol{
    vector<int>v[maxn];
    int n,m,T,ans;
    int a[maxn];
    inline int Main(){
        n=read(); m=read(); T=read();
        for(int i=1;i<=n;i++){
            a[i]=read();
            v[a[i]].push_back(i);
        }
        while(T--){
            ans=0;
            int l=read(),r=read(),x;
            if(l==r){puts("0");continue;}
            for(int i=l;i<=r;i++){
                if(r-i<=ans)break;//若是r-i比我当前搜到的答案短,那确定找不到了。continue
                if(v[x=a[i]].size()<2) continue;//若是找不到当前数字相等的点。continue
                if(v[x][v[x].size()-1]-i<=ans) continue; //
                //就是这三个剪枝,
                int xx=lower_bound(v[x].begin(),v[x].end()-1, r)-v[x].begin();
                if(v[x][xx]>r) xx-=1;//以上两行请本身理解/喷脸
                ans=max(ans,v[x][xx]-i);//更新答案
            }
            printf("%d\n",ans);
        }
        return 0;
    }
}
//不知为何,这题我用cin,cout居然只有10 pts/jk

T3颠倒黑白

连接

Idea

目前只知道std是爆搜?\喷脸

Code

//容我回来再补

\[ \mathcal The \quad End \]

\[ \text{我仍然在无人问津的阴雨霉湿之地;和着雨音唱着没有听众的歌曲-《世末歌者》} \]

相关文章
相关标签/搜索