ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1100. Final Standings

Runtime error (access violation) Please help me !! sad......
Posted by xinxin 18 Sep 2016 19:06
#include<stdio.h>
void merge(int a[],int b[],int c[],int d[],int left,int mid,int right)
{
    int i=left,j=mid+1;
    int k=left;
    while((i<=mid)&&(j<=right))
    {
        if(a[i]>=a[j])
        {b[k++]=a[i++];
        k--;
        i--;
        d[k++]=c[i++];}
        else
        {b[k++]=a[j++];
        k--;
        j--;
        d[k++]=c[j++];}
    }
    if(i>mid)
        for(int q=j;q<=right;q++)
        {b[k++]=a[q];
    k--;
         d[k++]=c[q];
    }
    else if(j>right)
        for(int q=i;q<=mid;q++)
        {b[k++]=a[q];
    k--;
    d[k++]=c[q];}
    for (int l = left;l <= mid;l++) {
        a[l] = b[l];
        c[l]=d[l];
    }
    for (int l = mid+1;l <= right;l++) {
        a[l] = b[l];
        c[l]=d[l];
    }
}
void mergesort(int a[],int b[],int c[],int d[],int left,int right)
{
    if(left<right)
    {
        int mid = (left + right) / 2;
        mergesort(a,b,c,d,left,mid);
        mergesort(a,b,c,d,mid+1,right);
        merge(a, b,c,d, left, mid, right);
    }
}
int main()
{
    int n,i;
    int c[15000],a[15000],b[15000],d[15000];
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d",&c[i]);

        scanf("%d",&a[i]);
    }
    mergesort(a,b,c,d,0,n-1);
    for(i=0;i<n;i++)
    {
        printf("%d %d\n",d[i],b[i]);
    }
    fflush(stdin);
    getchar();
    return 0;
}
Re: Runtime error (access violation) Please help me !! sad......
Posted by Oleg Baskakov 19 Sep 2016 02:16
I will solve all your issues with all your current non-AC tasks just for 0.01BTC :>
Re: Runtime error (access violation) Please help me !! sad......
Posted by xinxin 19 Sep 2016 11:28
too expensive~
Re: Runtime error (access violation) Please help me !! sad......
Posted by Oleg Baskakov 19 Sep 2016 11:32
Sorry then :)
Anyways, feel free to look into older threads of corresponding tasks, they might contain hints for your questions.
Re: Runtime error (access violation) Please help me !! sad......
Posted by xinxin 19 Sep 2016 11:35
thank you very much~~