Problem Description
XY is playing a game:there are N pillar in a row,which numbered from 1 to n.Each pillar has a jewel.Now XY is standing on the S-th pillar and the exit is in the T-th pillar.XY can leave from the exit only after they get all the jewels.Each time XY can move to adjacent pillar,or he can jump to boundary ( the first pillar or the N-th pillar) by using his superpower.However,he needs to follow a rule:if he left the pillar,he no can not get here anymore.In order to save his power,XY wants to use the minimum number of superpower to pass the game.
 

Input
There are multiple test cases, no more than 1000 cases.
For each case,the line contains three integers:N,S and T. (1N10000,1S,TN)
 

Output
The output of each case will be a single integer on a line: the minimum number of using superpower or output -1 if he can't leave.
 

Sample Input
4 1 4 4 1 3
 

Sample Output
0 1
 

Source
 


这个题完全证实了自己是在碰运气==WA一次发现一个错误

开始还由于想到了s-t==1||t-s==1时输出1 特得意,自以为是的觉得既然可以飞到1或者n就是对称的 (s==1||s==n)<==>(t==1||t==n)敲打

你试完了S==1和S==N就不能就手再试一次t==1||t==n吗???他俩一样吗?一样吗??发火

#include <iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int s,t,n;
int main()
{
    while(~scanf("%d%d%d",&n,&s,&t))
    {
        if(s==t)
        {
            if(n==1) puts("0");
            else puts("-1");
        }
        else
        {
            if(s==1&&t==n)puts("0");
            else if(s==n&&t==1)puts("0");
            //else if()puts("2");
            else if(s-t==1||t-s==1)puts("1");
            else if(s==1||s==n)puts("1");
            //else if()puts("1");
           // else if(t==1||t==n)puts("2");

            else printf("2\n");
        }
    }
    return 0;
}