|
|
back to boardWA on test case 1......please please help Posted by sarvin 26 Dec 2014 17:06 following is my solution in C.I have used qsort() function of library stdlib.I have checked it on all test cases but still I am not able to figure out which test case is getting wrong..please help...i have really spend a lot of time on this. #include<stdio.h> #include<stdlib.h> struct TwoInt { long int a; int b; }; typedef struct TwoInt Int; Int arr[200000]; int cmpfnc(const void* a,const void* b) { const int p=((const Int*)a)->b; const int q=((const Int*)b)->b; if(p>q) return q-p; else { if(p<q) return q-p; } return 0; } int main() { long int n; scanf("%ld",&n); long int i=0; for(i=0;i<n;i++) scanf("%ld %d",&(arr[i].a),&(arr[i].b)); qsort(arr,n,sizeof(Int),cmpfnc); for(i=0;i<n;i++) printf("%ld %d\n",arr[i].a,arr[i].b); return 0; } Re: WA on test case 1......please please help me too . :( Re: WA on test case 1......please please help Is C qsort() stable? P.S. Oops. Answer to necro-post... Edited by author 09.08.2016 17:46 |
|
|