Gray Code(CSES)

My output is also the same as the correct output in all the test cases but still giving WA.
I have used simple recursion to solve it. Plz, help.

here’s the link to the problem : CSES - Gray Code
here’s the link to my code: https://cses.fi/paste/08eda841e0f99e2121bc4c/

I have also pasted my code below.


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define M 1000000007

define endl ‘\n’

const int inf = 1e9 + 10;
const ll INF = 1e18 + 10;
void grayCode(string s,int i,int n)
{
if(i==n)
{
cout<<s<<endl;
return;
}

s.push_back('0');
grayCode(s,i+1,n);
s.pop_back();
s.push_back('1');
grayCode(s,i+1,n);

}

int main() {

ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);

int n;cin>>n;
string s = "";
grayCode(s,0,n);

return 0;

}

Actually the problem is not in code but in solution matching of website.