Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 40121

what is ioi style grading??

$
0
0

I am trying to solve problems from past ico's in ICO online judge.i solved a problem(NEXTPERM). After submission the solution was accepted but i scored only 20 out of 100.The judge is showing that my solution has given correct answer to all the test cases. What can be the cause of scoring so bad??how can i improve my score?? link to the problem:http://opc.iarcs.org.in/index.php/problems/NEXTPERM my answer:

#include<stdio.h>
int main()
{
 long int n,p[1001],a[1001],b,c,d,e=0,f,g=1,h,i,j,k;
 scanf("%ld %ld",&n,&k);
 for (j=1;j<=k;j++)
 {
  for (b=0;b<n;b++)
  {
    scanf("%ld",&a[b]);
  }
  //printf("\n");
  if (a[n-1]>a[n-2])
  {
    c=a[n-1];
    a[n-1]=a[n-2];
    a[n-2]=c;
    for(b=0;b<n;b++)
    {
     if (b!=n-1)
     printf("%ld ",a[b]);
     else
     printf("%ld",a[b]);
    }
  }
 else
 {
  for (b=n-2;b>1;b--)
  {
     if (a[b]>a[b-1])
     break;
  }
  c=a[b-1];
  for (d=b;d<n;d++)
  {
    if (c>a[d])
    break;
  }
  a[b-1]=a[d-1];
  a[d-1]=c;
  for (d=0;d<b;d++)
  p[d]=a[d];
  i=b;
  for (d=n-1;d>=b;d--)
  {
    p[i]=a[d];
    i++;
  }
  for (d=0;d<=n-1;d++)
  {
    a[d]=p[d];
    if (d!=n-1)
    printf("%ld ",a[d]);
    else
    printf("%ld",a[d]);
  }
 }
 printf("\n");
}
return 0;
}

Viewing all articles
Browse latest Browse all 40121

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>