题目链接:https://codeforces.com/contest/1582/problem/F2
先来说一下我的看法:这是我有史以来见过最牛逼最优雅的暴力
这个先放代码
#include <bits/stdc++.h>
using namespace std;
const int MAXN=(1<<13)-1;
vector<int>g[MAXN+5];
int r[MAXN+5];
bool ans[MAXN+5];
int main(){
	int n;
	cin>>n;
	for(int i=0;i<=MAXN;i++){
		g[i].push_back(0);
		r[i]=MAXN;
	}
	for(int i=1;i<=n;i++){
		int x;
		cin>>x;
		for(int j:g[x]){
			int to=j^x;
			ans[to]=1;
			while(r[to]>x){
				g[r[to]].push_back(to);
				r[to]--;
			}
		}
		g[x].clear();
	}
	int tot=0;
	for(int i=1;i<=MAXN;i++) tot+=ans[i];
	cout<<tot+1<<endl;
	cout<<0<<" ";
	for(int i=1;i<=MAXN;i++)
		if(ans[i]) cout<<i<<" ";
	return 0;
}
gi用以表示的在所有之前出现过的数字组成的上升子数列当中且结尾数字小于i的情况中能产生的异或和有哪些,然后ri代表的是异或和是数字i的序列步可再异或上的最大数字是多少

Comments NOTHING