I was trying to solve the question Stair Game on cses, and I came across a blog on codeforces, the blogs say that the even position in the stairs does not matter.
When I applied the above idea to the question it got accepted.
#include<bits/stdc++.h>
using namespace std;
int main(){
int t; cin>>t;
while(t--){
int n; cin>>n;
int xor_ = 0;
int x; cin>>x;
for(int i=1;i<n;i++){
int x; cin>>x;
//the balls, where k is odd do not matter why?
xor_ = i&1? xor_^x: xor_;
}
cout<<(xor_ ? "first\n": "second\n");
}
}
Can someone please give the reasoning behind the idea, why the even stair-cases does not matter?