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

题意:

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

思路:

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

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

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

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