## 10327 - Flip Sort

Moderator: Board moderators

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

### Re: 10327 - Flip Sort

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

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

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

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

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

### Re: 10327 - Flip Sort

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

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

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;
}

``````