建军节,解放军辛苦了,致敬!!
下面再说今天的考试QwQ
今天的模拟赛……终于不是爆零也不是倒数第一惹~
T1 string
最起码第一题拿到了大家都拿到的基础分40,知足常乐,慢慢进步。
sort考场上忘了咋用(一直把第二个参数当作区间长度)两个代码模拟了40分钟未果,于是手写俩冒泡交了,成功水到了部分分
然而我看出来了T1要用线段树维护,但是迫于不熟练,所以暴力了
![](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
#include <iostream> #include <cstring> #include <cstdio> #include <cmath> #include <algorithm> using namespace std; char ch[100005]; inline int read(){ int x=0,w=1; char ch=getchar(); for(;ch>'9'||ch<'0';ch=getchar()) if(ch=='-') w=-1; for(;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0'; return x*w; } int main(){ int n,m; n=read(),m=read(); for(int i=0;i<n;i++) cin>>ch[i]; int t,l,r; while(m--){ l=read(),r=read(),t=read(); if(t==0){ for(int i=l-1;i<=r-1;i++) for(int j=l-1;j<=i-1;j++) if((int)ch[i]>(int)ch[j]) swap(ch[i],ch[j]); } else if(t==1){ for(int i=l-1;i<=r-1;i++) for(int j=l-1;j<=i-1;j++) if((int)ch[i]<(int)ch[j]) swap(ch[i],ch[j]); } } for(int i=0;i<n;i++) cout<<ch[i]; cout<<endl; return 0; }