what is ioi style grading??

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:Contest Page | CodeChef
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;
}

perhaps you should look for a better and efficient algorithm…:slight_smile:
happy coding…:slight_smile:

1 Like

In IOI style grading even if u get a few test files correct then u get partial marking…each test file is assigned a particular weight-age…so even if 1-2 test files out of the predefined number of test files are correct while the others are giving a WA or RE or TLE…it shows AC status and gives u a partial score…hope this helps…:slight_smile:

EDIT: can u provide a link to the problem and the link to ur solution…!!!

EDIT 2: to increase ur score maybe u should check if u may be missing a few corner cases…or maybe some overflow maybe taking place or maybe some divide by zero(which may give RE) or maybe RE due to some segmentation fault(large array size) or maybe ur algo may not be efficient enough giving a TLE for the remaining test files so u may need to rethink on ur approach…!!!

For Your Information, the maximum score for that problem is 20

1 Like

A simpler solution!

m=map(int,raw_input().split())
n=m[0]
k=m[1]
for i in xrange(k):
    l=map(int,raw_input().split())
    for i in xrange(n-1):
	ii=n-1-i
	if l[ii]>l[ii-1]:
	    for j in xrange(ii,n):
		k=n-1+ii-j
		if l[k]>l[ii-1]:
		    l[ii-1],l[k]=l[k],l[ii-1]
		    l[ii:]=sorted(l[ii:])
		    break
	    break
    ans=''
    for i in xrange(n):
	ans+=str(l[i])
	ans+=' '
    print ans

Algorithm explained here . Hope this helps

i have added my answer and the problem link

1 Like