ENOC3 -- Need help!

I don’t know why my solution is getting WA. Although I have seen some of the successful submissions wherein same brute force approach has been applied. The same brute force method I have applied and got WA.
Link to my solution
https://www.codechef.com/viewsolution/27628855
Link to Problem page

Help will be appreciated !!
Thanks

I also got WA. CodeChef: Practical coding for everyone Don’t know what is wrong. Please someone check.

For a string of length = 2, the answer string should be of length = 1 as the pair of indices shouldn’t repeat.

1 Like

Thanks for help

1 Like

/*
@Author
Just a gyroman’s piece of code

*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
#define lim 1000006
#define fast ios_base::sync_with_stdio(false)
#define fast_input cin.tie(NULL)
#define fast_output cout.tie(NULL)
void solve()
{
string s;
cin>>s;
if(s.length()==1)
cout<<s;
else
{ int i;
int n=s[0]-‘0’;
for(i=0;i<s.length()-1;++i)
{
int a,b;
char a1,b1;
// a1=s[i];
// b1=s[i+1];
a=s[i]-‘0’;
b=s[i+1]-‘0’;
cout<<(a^b);

    }
    int kk=s[i]-'0';
    cout<<(kk^n);

}
}
int main() {
fast;
fast_input;
fast_output;

ll t;
cin>>t;
while(t--)
{
    solve();
    cout<<"\n";
}


return 0;

}

This code is not doing the same

https://www.codechef.com/viewsolution/27634527
Link to the above solution which is accepted

Oh, then I have no idea why the above codes are giving WA. :sweat_smile:

@ransh u missed the case when length of N = 1,then it should print the number As it is

1 Like

i have done it
but got wa

Then how the below solution got accepted.
Link to accepted solution
https://www.codechef.com/viewsolution/27629865

Above solution for input
1
23
is giving answer 11.
How it got accepted.

@rana_1234 this is because i didn’t introduced test case for a 2 digit number manually,the test cases were randomly generated hence there was no 2 digit number to filter the submission

so the problems have not been fully verified for better test cases before the contest

Thanks all of you.
I found the bug in my code.
int XOR[9][9] ;
Declared XOR[0…8][0…8] only. Should have declared XOR[10][10].

:innocent::innocent:
Thanks everybody to take part in the discussion.

1 Like

@vipulsnp the test cases were changed before the contest because the formate of the test file had some issues…hence the new set of test cases weren’t that strong