In this problem(DIV2.C) I printed the right answer but the code forces judge is showing it wrong, Why? Can anyone point out my mistake? My code is
void task() {
str s; cin >> s; int n = s.size();
cout << 3 << endl;
cout << "R " << n - 1 << endl;
cout << "L " << n << endl;
cout << "L " << n - 1 << endl;
}
In the first test case, abac
my output is(which is always the same)->
3
R 5
L 6
L 5
which I think is right.
UPD — Why all are downvoting? if there is any mistakes or error than please let me know.
Are you sure it is right? Have you checked the editorial?
Yes I checked. Though it was clear from the editorial to print always only 4 lines but You can see that with my output in 1st test case you can actually build a palindrome string .
Have you tried any other testcases?
You should put:
cout << "L " << 2 << endl;
in the last line
But putting
L 5
in end also giving palindrome string.But for this case and a bunch of more cases only not on all. I can give counter example
So you are saying that just print those 3 lines written in editorial. But can you tell what's wrong in my code?
Take string as "abcd".
Then final string will be: " abcdcbabcdc"
Auto comment: topic has been updated by pr_iy_an_sh_ut_iw_ar_i (previous revision, new revision, compare).