Cod sursa(job #988768)

Utilizator Athena99Anghel Anca Athena99 Data 23 august 2013 20:08:47
Problema Multimi2 Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 1.68 kb
#include <cassert>
#include <cstdio>

int main()
{
    int n=0,b=0,e=0;

    assert(freopen("multimi2.in","r",stdin));
    assert(freopen("multimi2.out","w",stdout));

    assert(scanf("%d",&n));
    if (n==2)
        printf("1\n1\n1\n1\n2\n");
    else if (n==3)
        printf("0\n2\n1 2\n1\n3\n");
    else if (n%4==0)
    {
        printf("0\n%d\n",n/2);
        b=1,e=n;
        while (b<e)
        {
            printf("%d %d ",b,e);
            b+=2,e-=2;
        }
        printf("\n%d\n",n/2);
        b=2,e=n-1;
        while (b<e)
        {
            printf("%d %d ",b,e);
            b+=2,e-=2;
        }
    }
    else if (n%4==1)
    {
        printf("1\n%d\n1 ",n/2+1);
        b=2,e=n;
        while (b<e)
        {
            printf("%d %d ",b,e);
            b+=2,e-=2;
        }
        printf("\n%d\n",n/2);
        b=3,e=n-1;
        while (b<e)
        {
            printf("%d %d ",b,e);
            b+=2,e-=2;
        }
    }
    else if (n%4==2)
    {
        printf("1\n%d\n1 ",n/2);
        b=3,e=n;
        while (b<e)
        {
            printf("%d %d ",b,e);
            b+=2,e-=2;
        }
        printf("\n%d\n2 ",n/2);
        b=4,e=n-1;
        while (b<e)
        {
            printf("%d %d ",b,e);
            b+=2,e-=2;
        }
    }
    else if (n%4==3)
    {
        printf("0\n%d\n1 2 ",n/2+1);
        b=4,e=n;
        while (b<e)
        {
            printf("%d %d ",b,e);
            b+=2,e-=2;
        }
        printf("\n%d\n3 ",n/2);
        b=5,e=n-1;
        while (b<e)
        {
            printf("%d %d ",b,e);
            b+=2,e-=2;
        }
    }

    return 0;
}