显示代码纯文本
- #include<cstdio>
- #include<stack>
- using namespace std;
- long long a[1001];
- int vis[1001]={0};
- long long sum=0;
- int ok=0;
- int tot=0;
- stack<long long> s,q;
- int dfs(int k, int n)
- {
- for(int i=k+1;i<=n;i++)
- { if(ok==1) return 0;
- if(!vis[i])
- {
- long long he=sum;
- sum^=a[i];
- // printf("%d\n",sum);
- vis[i]=1;
- if(sum==0)
- {s.push(i);ok=1;return 0;}
- else
- {
-
- s.push(i);tot++;
- dfs(i,n);
- if(ok==1) return 0;
- s.pop();
- vis[i]=0;
- sum=he;
- }
- }
- }
- }
-
-
-
- int main()
- {
- int n;
- freopen("asm_contribute.in","r",stdin);
- freopen("asm_contribute.out","w",stdout);
- scanf("%d",&n);
- for(int i=1;i<=n;i++)
- scanf("%lld",&a[i]);
- dfs(0,n);
- // printf("%d\n",tot);
- printf("%d\n",s.size());
- while(s.size())
- {
- long long u=s.top();
- s.pop();
- q.push(u);
- }
- while(q.size())
- {
- long long u=q.top();
- q.pop();
- printf("%lld ",u);
- }
- return 0;
- }