#include <iostream.h>
using namespace std;
int main() { int t ,j; cin>>t; for(j=0 ;j<t ;j++) { int n, m ,q ,r ,parth=1 , khushi=1 ,k ,l ,sum1=0,sum2=0; cin>>n>>m; q=m/n; cout<<q<<" "; if(q!=0) { int p; p=qn; int arr[p]; sum2=(n(n+1))/2;
for(k=0;k<p ;k++) { arr[k]=0; } for(k=0;k<q ;k++) { for(l=n*k ;l<n*k+n ;l++) { cin>>arr[l]; sum1=sum1+arr[l]; cout<<sum1<<" "; } cout<<endl; if(sum1!=sum2) { parth=0; break; } sum1=0; } } r=m%n; if(r!=0) { int arr2[r],hash[n+1]; hash[0]=0; for(k=1;k<=n;k++) { hash[k]=0; } for(k=0;k<r;k++) { arr2[k]=0; } for(k=0;k<r;k++) { cin>>arr2[k]; hash[arr2[k]]++; } for(k=0;k<r;k++) { if(hash[arr2[k]]>1) { khushi=0; break; } } } if(parth==1 && khushi ==1) { cout<<"YES"<<" "<<parth<<" "<<khushi<<endl; } else { cout<<"NO"<<" "<<parth<<" "<<khushi<<endl; parth=1; khushi=1; } } return 0;
}
Asked by: Anonymous on March 31, 2020, 1:10 p.m. Last updated on March 31, 2020, 1:10 p.m.
due to some pre--processing done by markdown language some parts of your code can be missed
for example you written as sum2=(n*(n+1))/2;
which is converted as sum2=(n(n+1))/2; in above solution
there may be many things like this so we are unable to find errors properlly
so send a link to your solution and also problem
always send a link to problem statment and solution(if there is one).
any way I am up with a solution to this
solution: click here
to know what errors you have made send your link in comment section
cout<<sum1; is deleted cout<<parth<<khushi is also deleted
parthvyasvadodara last updated on March 31, 2020, 1:19 p.m.