10327 - Flip Sort

All about problems in Volume 103. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 10327 - Flip Sort

Post by brianfry713 » Tue Jun 18, 2013 1:19 am

Your code never terminates.
Check input and AC output for thousands of problems on uDebug!

habib_ruet_cse_12
New poster
Posts: 1
Joined: Sat Dec 07, 2013 7:47 pm

10327 - Flip Sort

Post by habib_ruet_cse_12 » Sat Dec 07, 2013 7:51 pm

I think the problem has some difficulties. Why i can,t change the values between each other. why i can't swap. with out swapping i can't sort my values... Admin please clear me...

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 10327 - Flip Sort

Post by brianfry713 » Tue Dec 10, 2013 12:51 am

Check input and AC output for thousands of problems on uDebug!

xrenon
New poster
Posts: 10
Joined: Tue Sep 23, 2014 4:11 am

Re: 10327 - Flip Sort

Post by xrenon » Sat Oct 11, 2014 6:33 pm

DELETED
Last edited by xrenon on Sun Oct 12, 2014 2:55 pm, edited 1 time in total.

lighted
Guru
Posts: 585
Joined: Wed Jun 11, 2014 9:56 pm
Location: Kyrgyzstan, Bishkek

Re: 10327 - Flip Sort

Post by lighted » Sun Oct 12, 2014 1:15 pm

In this approach only one operation ( Flip ) is available and that is you can exchange two adjacent terms.
According to problem description you can exchange only two adjacent terms.
A person who sees the good in things has good thoughts. And he who has good thoughts receives pleasure from life... Bediuzzaman

quanghm
New poster
Posts: 5
Joined: Sat Apr 25, 2015 4:00 pm

Re: 10327 - Flip Sort

Post by quanghm » Fri May 01, 2015 9:27 pm

I would like to argue that the problem is ill-posed. At least, there's a conflict between the text (a number N followed by several lines) while the sample input showed two data sets with two "different" N as one can see in the sample output.

The reference program at udebug seemed to agreed with the problem text, but seems to ignore the number N and process each line individually. For example

3
1 2 3
3 2 1
4
1 2 3 4
4 2 3 1

would give 5 lines and treats the last 3 lines as permutation on 4 letters, not 3.

fayed22
New poster
Posts: 1
Joined: Sat May 23, 2015 7:37 pm

Re: 10327 - Flip Sort

Post by fayed22 » Sat May 23, 2015 7:46 pm

why my code is getting is runtime error...plz help..

Code: Select all

#include<stdio.h>
int main()
{
    int i,p[100],n,b,j,count;
    while((scanf("%d",&n))==1&&n!='\0')
    {
        count=0;
        for(i=0;i<n;i++)
        {
            scanf("%d",&p[i]);
        }
        for(i=0;i<n-1;i++)
        {
            for(j=0;j<n-i-1;j++)
            if(p[j]>p[j+1])
            {
                b=p[j];
                p[j]=p[j+1];
                p[j+1]=b;
                count++;
            }
        }
        printf("Minimum exchange operations : %d\n",count);
    }
    return 0;
}


Post Reply

Return to “Volume 103 (10300-10399)”