THIS IS MY CODE. IT GIVES WA. HELP PLS!!
#include <bits/stdc++.h>
using namespace std;
int main()
{ ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int T,N,A[100];
cin>>T;
for(int j=0;j<T;j++)
{cin>>N;
if(N==1)
{cin>>A[0];
cout<<A[0];
else
{for(int i=0;i<N;i++)
cin>>A[i];
cout<<A[0];
if(!(A[1]==A[0]+1&&A[1]==A[2]-1))
cout<<’,’;
for(int i=1;i<N-1;i++)
{
if((A[i]==A[i-1]+1&&A[i]==A[i+1]-1))
cout<<"…";
else
{cout<<A[i];
if(!(A[i+1]==A[i]+1&&A[i+1]==A[i+2]-1))
cout<<’,’;}
}
cout<<A[N-1]<<endl;
}}
return 0;
}
Please either format your code or (better!) link to your submission - the forum software has mangled it and it won’t compile!
2 Likes
ssjgz
March 12, 2020, 8:06am
4
This solution doesn’t even compile
1 Like
ssjgz
March 12, 2020, 9:06am
6
Thanks - one thing that immediately leaps out is that you are printing the single character:
…
instead of 3 .
s:
...
1 Like
is there any difference created due to that.
did it as a string of …
ssjgz
March 12, 2020, 9:15am
8
Codechef requires your output to be identical to the expected output (except with whitespace in certain places).
1 Like
ssjgz
March 12, 2020, 9:28am
10
This prints out commas (,
) instead of dots (.
)
1 Like
ssjgz
March 12, 2020, 9:34am
13
Better - we’re printing out the correct characters, now
This solution gives the wrong answer for the sample testcase: I recommend debugging and getting it to give the right answer for the sample testcase before submitting again
1 Like
this is done using codeblocks.
also in the ques string “…” was mentioned