跳到正文

个人记录

帮帮我

MobiusInversion约 1 分钟
原文
文章信息与版本

文章信息

收录
2025年12月12日
更新
2026年5月19日
篇幅
约 1 分钟

版本

  1. v1当前

P2574 XOR的艺术

C++
#include<bits/stdc++.h>
using namespace std;
const int N=1e5;
int n,m;
int main(){
    string str;
	cin>>n>>m;
    cin>>str;
    bitset<N> a(str),b(str);
    b.set();
	while(m--){
		int op,l,r;
		cin>>op>>l>>r;
		if(op==0){
			a^=((b>>(N-r+l-1))<<(l-1));
		}else{
			cout<<(a&((b>>(N-r+l-1))<<(l-1))).count()<<endl;
		}
	}
	return 0;
}
C++
output:

6
3
2
原文