2016 NEERC Northern Subregional Contest A Anniversary Cake (水题)

题意:

W_H的方格纸,共有(w+1)_(H+1)个整点,现在将2个蜡烛放在2个不同的整点上。蜡烛不会被放在边界上。现在给出方格纸的尺寸和2个蜡烛的坐标,求一条线段将方格纸拆成2部分,而且这条线段不经过任何一个蜡烛且使得每一部分恰好有一个蜡烛。问线段的起点和终点。

思路:

为了方便讨论,我们将x坐标小的设为蜡烛1,另一个设为蜡烛2.

分两种情况讨论,即横坐标相同和不同2种情况。

需要注意的是...要交文件orz

/* ***********************************************
Author :111qqz
Created Time :2017年10月02日 星期一 12时34分38秒
File Name :A.cpp
************************************************ */
 1#include <cstdio>
 2#include <cstring>
 3#include <iostream>
 4#include <algorithm>
 5#include <vector>
 6#include <queue>
 7#include <set>
 8#include <map>
 9#include <string>
10#include <cmath>
11#include <cstdlib>
12#include <ctime>
13#define PB push_back
14#define fst first
15#define sec second
16#define lson l,m,rt<<1
17#define rson m+1,r,rt<<1|1
18#define ms(a,x) memset(a,x,sizeof(a))
19typedef long long LL;
20#define pi pair < int ,int >
21#define MP make_pair
 1using namespace std;
 2const double eps = 1E-8;
 3const int dx4[4]={1,0,0,-1};
 4const int dy4[4]={0,-1,1,0};
 5const int inf = 0x3f3f3f3f;
 6LL w,h,ax,ay,bx,by;
 7int main()
 8{
 9    freopen("anniversary.in","r",stdin);
10    freopen("anniversary.out","w",stdout);
11    cin>>w>>h>>ax>>ay>>bx>>by;
12    if (ax>bx)
13    {
14        swap(ax,bx);
15        swap(ay,by);
16    }
17    if (ax!=bx)
18    {
19        printf("%lld %lld %lld %lld\n",ax,0LL,ax+1,h);
20    }
21    else
22    {
23        LL my = min(ay,by);
24        printf("%lld %lld %lld %lld\n",0LL,my,w,my+1);
25    }
    return 0;
}