玄学问题
查看原帖
玄学问题
856004
Grammar_hbw楼主2024/6/27 15:17

为什么下面的代码,把标有AC的行换成标有RE的行就会RE on test 57?它们不是等价的吗?

#include <bits/stdc++.h>
using namespace std;
const int maxa=8207;
vector<int> f[maxa];
int g[maxa];
bitset<maxa> ans;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	ans[0]=1;
	for(int i=0;i<8192;i++) f[i].push_back(0),g[i]=8191;
	int n;
	cin>>n;
	for(int i=1,a;i<=n;i++){
		cin>>a;
		for(int j=0;j<f[a].size();j++){  //AC
			int x=f[a][j]^a;  //AC
	//	for(auto j:f[a]) {  //RE
		//	int x=j^a;  //RE
			ans[x]=1;
			while(g[x]>a) f[--g[x]].push_back(x);
		}
		f[a].clear();
	}
	cout<<ans.count()<<'\n';
	for(int i=0;i<8192;i++) if(ans[i]) cout<<i<<' ';
	cout<<'\n';
}
2024/6/27 15:17
加载中...