cassert
is the header file that includes the declaration of the assert
macro, which I’ve used in my read
function to check that I’m reading the input correctly.
Kya baat…
Can anyone help me out to find which case I am missing?
Here is my solution
Passes the second part but failed in first.
Consider the test input:
1
12
1 2 3 4 5 6 6 5 4 3 2 1
https://www.codechef.com/viewsolution/48077638
@ssjgz could you please give me a test case where this code is giving WA.
Please help me.
1
12
1 2 3 4 5 6 6 5 4 3 2 1
Codechef please remove this problem from beginner level, it can be easy or medium level.
Not sure about java but if you have implemented a condition to check if numbers in array occur in order 1,2,3… then it will show error.
Eg: if your code shows ‘no’ for 2 1 3 4 5 7 6 7 5 4 3 1 2, then answer will be considered wrong. I think the test cases are weak.
NO
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define ld long double
#define mp map<ll,ll>
#define mpc map<char,ll>
#define mps map<string,ll>
#define pb push_back
#define pll pair<ll,ll>
#define vll vector
#define vpll vector<pair<ll,ll>>
#define prq priority_queue//max
#define prqs priority_queue<ll,vector,greater>//min
#define m_p make_pair
#define ff first
#define ss second
#define b_s binary_search
#define l_b lower_bound
#define u_b upper_bound
#define l(i,s,e) for(ll i=s;i<e;i++)
#define Test ll t;cin>>t;while(t–)
#define all(v) v.begin(),v.end()
#define mem(a,x) memset(a,x,sizeof(a))
#define ln ‘\n’
#define yes cout<<“YES\n”;
#define no cout<<“NO\n”;
const ll mod =1e9+7;
const ull INF=1e9;
void fast(){
ios_base::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
}
int main(){
fast();
ll t;
cin>>t;
while(t–){
ll n;
cin>>n;
ll a[n];
for(ll i=0;i<n;i++){
cin>>a[i];
}
ll ans=0,r=1,p=1;
for(ll i=0;i<=n/2;i++){
if((a[i]==a[n-i-1])){
}
else{
ans=1;
break;
}
}map<ll,ll>m;
if(ans==0){
for(ll i=0;i<=n/2;i++){
m[a[i]]++;
}
for(ll i=0;i<=n/2;i++){
for(ll j=i+1;j<=n/2;j++){
if(a[i]<=a[j]){
continue;
}
else {
ans=1;
break;
}
}
}
}
if(ans==0&&m.size()==7&&a[0]==1&&a[n/2]==7)
cout<<“yes”;
else
cout<<“no”;
cout<<endl;
}
}
/* package codechef; // don’t place package name! */
import java.util.;
import java.lang.;
import java.io.*;
/* Name of the class has to be “Main” only if the class is public. */
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
Scanner sc=new Scanner(System.in);
int t = sc.nextInt();
while(t–>0)
{
int n=sc.nextInt();
int a[]=new int[n];
int b[]=new int[n];
Arrays.fill(a,0);
Arrays.fill(b,0);
int x=1;
for(int i=0;i<n;i++)
{
a[i]=sc.nextInt();
if(i>0 && a[i]!=a[i-1] && x<8)
x++;
if( a[i]==x && b[i]==0 && b[n-i-1]==0)
{
b[i]=a[i];
if(a[i]!=7)
b[n-i-1]=a[i];
}
}
System.out.println(Arrays.equals(a,b)?"yes":"no");
}
}
}
I am getting WA…can anybody plz find what’s wrong in my solution and tell me which test
case am I missing …plzzz
Please either format your code or (better!) link to your submission - the forum software has mangled it and it won’t compile!
output is yes in VScode IDE as well as CodeChef IDE as custom input. But the Codechef IDE give the wrong answer as I submit the code
The correct output is no
.
Can you explain, how?
here is my solution (definitely wrong ):
https://www.codechef.com/viewsolution/57402093
can anyone point out where my code is failing.