#include<stdio.h>
#include<stdlib.h>
//始点固定してキューを利用して幅優先探索
//カウントダブった分/2して出力

struct pos {
    int num;
    struct pos *next;
};


//リスト操作
typedef int elementtype;
struct node {
    elementtype element;
    struct node *next;
};

typedef struct node *link;

struct queue{
    link front, rear;
};

struct node *initlist(void){
    struct node *n;
    n = (struct node*)malloc(sizeof(struct node));
    n->next = NULL;
    return n;
}
void insert(struct node *p,elementtype x){
    struct node *n;
    n = (struct node*)malloc(sizeof(struct node));
    n->element = x;
    n->next = p->next;
    p->next = n;
}
void delete(struct node *p){
    if(p->next!=NULL){
        p->next = p->next->next;
    }
}

//キューの実装
void initqueue(struct queue *q){
    q->front = initlist();
    q->rear = q->front;
}

int queueempty(struct queue q){
    return q.front->next==NULL;
}
void enqueue(struct queue *q,elementtype x){
    insert(q->rear,x);
    q->rear = q->rear->next;
}
elementtype dequeue(struct queue *q){
    elementtype retval;
    if(queueempty(*q)){
        printf("underflow\n"); exit(1);
    }else{
        retval = q->front->next->element;
        delete(q->front);
        if(queueempty(*q)){
            q->rear = q->front;
        }
        return retval;
    }
}

//隣接リスト表現

void init_adjlist(struct pos *adjlist[], int size){
    int i;
    for(i=1;i<=size;i++){
        adjlist[i] = (struct pos*)malloc(sizeof(struct pos));
        adjlist[i]->next = NULL;
    }
}

void add_edge(struct pos *adjlist[], int mynum, int nextnum){
    struct pos *p = (struct pos*)malloc(sizeof(struct pos));
    p->num = nextnum; p->next = adjlist[mynum]->next;
    adjlist[mynum]->next = p;
}

int main(void){
    int n,x,y;
    scanf("%d %d %d", &n,&x,&y);
    struct pos *adjlist[n+1];
    init_adjlist(adjlist, n);
    int i,j;
    for(i=1;i<n;i++){
        add_edge(adjlist, i, i+1);  //i->i+1の連結
        add_edge(adjlist, i+1, i); //逆方向
    }
    add_edge(adjlist,x,y);  //x->yの連結
    add_edge(adjlist,y,x);


    int count[n]; //答え
    int distance[n+1]; //距離
    for(i=0;i<n;i++){
        count[i] = 0; //k=1 to  n-1
        distance[i] = 0;    //distance from tmp to i
    }
    distance[n] = 0;
    int flag[n+1];    //探索済みフラグ

    struct pos *head[n+1];
    init_adjlist(head, n);
    for(i=1;i<=n;i++){
        head[i] = adjlist[i];
    }

    //各始点についてなぞり開始
    for(i=1;i<=n;i++){
        for(j=1;j<=n;j++){
            flag[j] = 0;
            distance[j] = 0;
            adjlist[j] = head[j];
        }
        struct queue q; initqueue(&q);
        flag[i] = 1; distance[i] = 0;
        enqueue(&q, i);

        while(!queueempty(q)){
            int tmp;
            tmp = dequeue(&q);
            //printf("%d ",tmp);
            while(adjlist[tmp]->next!=NULL){
                adjlist[tmp] = adjlist[tmp]->next;
                if(flag[adjlist[tmp]->num] == 0){
                    enqueue(&q,adjlist[tmp]->num);
                    distance[adjlist[tmp]->num] = distance[tmp]+1;
                    flag[adjlist[tmp]->num] = 1;
                }
            }

        }

        /*
        for(j=1;j<=n;j++){
            printf("%d ", distance[j]);
        }
        printf("\n");
        */

        for(j=1;j<=n;j++){
            count[distance[j]]++;
        }
    }

    for(i=1;i<n;i++){
        printf("%d\n", count[i]/2);
    }

    return 0;

}

Measured memory_bytes: 125568