question :https://hack.codingblocks.com/contests/c/509/194
I am unable to pass 4th and the last 9th test case, can you please tell me what those cases are , so that i can work upon it.
Split into increasing decreasing sequence
hey @LPLC0150, there is something wrong in problem statement,
You have to print true if following cases are in output:
sequence can be entirely increasing
sequence can be entirely decreasing
sequence can be first increasing and the decreasing
sequence can be first decreasing and then increasing
Try to modify the your code according to these cases. If you have already done that getting these testcases failed, you can open editorial to view the testcases.
Since , this question is part of a contest, I am unable to see any any editorial or test cases . I need to know the exact test cases please
hey @LPLC0150,
testcase no 4
input
5
5
4
5
4
3
output
false
testcase 9
input
5
5
4
3
4
5
output
true
Sir, if these are the cases then i am already getting correct answer in my ide(code blocks),
but still they show up as wrong answer when I submit them in above contest.Can you check whats wrong:
hey @LPLC0150, share me your email, I will share you all the testcases. If even they don’t work,revert me.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.
Sir, can you tell me case 3 and 8 both same ,
input : 5 1 2 3 2 1
output: false
How is this possible , it can be split into 1 2 3 and 21 , so two sequences increasing and decreasing , so true answer
Am I missing something ?
hey @LPLC0150, read the condition, s1 to si and si+1 to sN such that first sequence is strictly decreasing and second is strictly increasing.
Decrease first and increase later.
Passed all test cases
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
ll n; cin>>n;
ll start; cin>>start;
n--;
ll increase = 0;
while(n--)
{
ll no; cin>>no;
if((no<start && increase==0) || (no>start && increase==1))
start = no;
else if(no>start && increase==0)
{
start = no;
increase =1;
}
else
{
cout<<"false\n";
return 0;
}
}
cout<<"true\n";
// cout<<start;
return 0;
}