2019.08.01NOIP模拟11

建军节,解放军辛苦了,致敬!! 

 


 

下面再说今天的考试QwQ  

今天的模拟赛……终于不是爆零也不是倒数第一惹~

T1 string

最起码第一题拿到了大家都拿到的基础分40,知足常乐,慢慢进步。

sort考场上忘了咋用(一直把第二个参数当作区间长度)两个代码模拟了40分钟未果,于是手写俩冒泡交了,成功水到了部分分

然而我看出来了T1要用线段树维护,但是迫于不熟练,所以暴力了

 

#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;
}
40

 

转载于:https://www.cnblogs.com/rui-4825/p/11285202.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值