wa求助
查看原帖
wa求助
482660
konyakest楼主2022/1/22 17:03

我的代码是对该过程的纯模拟,一定TLE,但我想问问s2的wa是什么情况

#include <bits/stdc++.h>
#define F(i,j,k) for(int i=int(j);i<=int(k);i++)
typedef long long LL;
using namespace std;
char bit[500001];
int n,q,l,r;
char t;
LL x,highbit,lowbit;
const int mod=1000000007;
int main() {
//	freopen("C:\\Users\\Administrator\\Desktop\\1.txt","r",stdin);
//	ios::sync_with_stdio(0);
//	cin.tie(0);
	cin>>n>>q;
	scanf("%s",bit+1);
	F(i,1,q) {
		cin>>l>>r>>x;
		LL temp;
		F(j,l,r) {
			if(bit[j]=='0') {
				lowbit=x&(-x);
				x+=lowbit;
				x%=mod;
			} else {
				highbit=1;
				temp=x;
				while(temp) {
					temp>>=1;
					highbit<<=1;
				}
				highbit>>=1;
				x+=highbit;
				x%=mod;
			}
		}
		cout<<x<<endl;
	}
	return 0;
}
2022/1/22 17:03
加载中...