题解 | #小红的区间查询#
小红的区间查询
https://www.nowcoder.com/practice/cbaecf16197a4136b8a593a7a270f4ab
#include <iostream>
using namespace std;
int a[250];
int main() {
int n, q;
cin >> n >> q;
for(int i = 1; i <= n; i++) cin >> a[i];
while(q--){
int type, pos, x;
cin >> type >> pos >> x;
if(type == 1){
a[pos] = x;
}
else{
int cnt = 0;
for(int i = 1; i <= pos; i++){
if(a[i] == x) cnt++;
}
cout << cnt << endl;
}
}
}
一看这个数据范围, 什么也不想了, 果断暴力模拟!
#悬赏#