What is the problem with this code? Only the first substask is passing.
Please can u provide the test cases. #include #include
using namespace std;
int main()
{
long long int t,n,k,i,x,y;
cin>>t;
while(t–)
{
cin>>n>>k;
char arr[n];
for(i=0;i<n-1;i+=2)
{
arr[i]=‘(’;
arr[i+1]=‘)’;
}
// cout<<endl;
// cin>>x>>y;
// arr[x]=‘(’;
// arr[y]=‘)’;
// low=x;
// high=y;
//k=k-1;
while(k–)
{
cin>>x>>y;
for(i=x;i<y;i+=2)
{
//if(arr[i]==‘(’)
// break;
//else
{
arr[i]=‘(’;
arr[i+1]=‘)’;
}
I have never got so may wrong answers for a question as in this one.Still unable to find a test case where this fails.Please someone find a test case for me…I have matched with all the test cases of this page and all those cases works fine in my code…Link to my code: https://www.codechef.com/viewsolution/7951755
I have to re-post it, but still the question in practice is still accepting the incorrect solutions and it gave wrong answer to my correct solution, that’s totally disappointing from the codechef…
Codechef should also not include this contest for calculating the rating coz it has an erroneous problem which gave many users including me WA during the contest and the actual in-correct solution were passed giving them AC… one way for codechef to improve and make up for their error…
Why you are putting a ‘)’ at the end and ‘(’ at the beginning. It is given that only the queries are always balanced but no description about the string(original string) it can be balanced/unbalanced.
That’s true, but then it doesn’t matter what I am giving at the end anyway. In case there was a query involving the ends, they would have been ‘(’ for the start and ‘)’ for the end anyway. And if there wasn’t, then it doesn’t matter what I am giving here.
Can you/anybody help me with a test case for which this could fail?
I think the test case is invalid. No correct arrangement can be made satisfying the test case. Would be surprised if you come up with a correct answer for the test case.