题解 | #小红的区间查询#

小红的区间查询

https://www.nowcoder.com/practice/cbaecf16197a4136b8a593a7a270f4ab

暴力模拟。

#include<bits/stdc++.h>
#define int long long
#define double long double
#define x first
#define y second
using namespace std;
typedef long long LL;
typedef long long ll;
typedef pair<int,int> PII;
const int N=3e5+10;
const int M=1e3+10;
int mod=1e9+7;
int a[N];

void solve(){
    int n,q;cin>>n>>q;
    for(int i=1;i<=n;i++) cin>>a[i];
    while(q--){
        int op;cin>>op;
        int i,x;cin>>i>>x;
        if(op==1) a[i]=x;
        else{
            int ans=0;
            for(int j=1;j<=i;j++) if(a[j]==x) ans++;
            cout<<ans<<'\n';
        }
    }
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    int _blank;
    _=1;
    //cin>>_;
    while(_--){
        solve();
    }
}

全部评论
Orz
点赞 回复 分享
发布于 2024-11-20 13:15 湖北

相关推荐

10-22 12:03
山东大学 Java
程序员小白条:26届一般都得有实习,项目可以随便写的,如果不是开源社区的项目,随便包装,技术栈也是一样,所以本质应该找学历厂,多投投央国企和银行,技术要求稍微低一点的,或者国企控股那种,纯互联网一般都得要干活
应届生简历当中,HR最关...
点赞 评论 收藏
分享
用微笑面对困难:你出于礼貌叫了人一声大姐,大姐很欣慰,她真把你当老弟
点赞 评论 收藏
分享
评论
2
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务