B. Bad Boy Codeforces Round #726 (Div. 2)

B. Bad Boy
Riley is a very bad boy, but at the same time, he is a yo-yo master. So, he decided to use his yo-yo skills to annoy his friend Anton.

Anton’s room can be represented as a grid with n rows and m columns. Let (i,j) denote the cell in row i and column j. Anton is currently standing at position (i,j) in his room. To annoy Anton, Riley decided to throw exactly two yo-yos in cells of the room (they can be in the same cell).

Because Anton doesn’t like yo-yos thrown on the floor, he has to pick up both of them and return back to the initial position. The distance travelled by Anton is the shortest path that goes through the positions of both yo-yos and returns back to (i,j) by travelling only to adjacent by side cells. That is, if he is in cell (x,y) then he can travel to the cells (x+1,y), (x−1,y), (x,y+1) and (x,y−1) in one step (if a cell with those coordinates exists).

Riley is wondering where he should throw these two yo-yos so that the distance travelled by Anton is maximized. But because he is very busy, he asked you to tell him.

Input
The first line contains a single integer t (1≤t≤104) — the number of test cases. Then t test cases follow.

The only line of each test case contains four integers n, m, i, j (1≤n,m≤109, 1≤i≤n, 1≤j≤m) — the dimensions of the room, and the cell at which Anton is currently standing.

Output
For each test case, print four integers x1, y1, x2, y2 (1≤x1,x2≤n, 1≤y1,y2≤m) — the coordinates of where the two yo-yos should be thrown. They will be thrown at coordinates (x1,y1) and (x2,y2).

If there are multiple answers, you may print any.

Example
inputCopy
7
2 3 1 1
4 4 1 2
3 5 2 2
5 1 2 1
3 1 3 1
1 1 1 1
1000000000 1000000000 1000000000 50
outputCopy
1 2 2 3
4 1 4 4
3 1 1 5
5 1 1 1
1 1 2 1
1 1 1 1
50 1 1 1000000000
Note
Here is a visualization of the first test case.

思路:对角最大(我感觉我写烦了)

#include<iostream>
#include<set>
#include<map>
using namespace std;
#define int long long
signed main()
{
    int t;
    cin>>t;
    while (t--)
    {
        int a,b,c,d;
        cin>>a>>b>>c>>d;
        if (a==1&&b==1)
        {
            cout<<1<<" "<<1<<" "<<1<<" "<<1<<endl;
        }
        else if (a==1) 
        {
            cout<<1<<" "<<1<<" "<<1<<" "<<b<<endl;
        }
        else if (b==1)
        {
            cout<<1<<" "<<1<<" "<<a<<" "<<1<<endl;
        }
        else
        {
            if (c==1&&d==1)
            {
                cout<<1<<" "<<1<<" "<<a<<" "<<b<<endl;
            }
            else if (c==1&&d==b)
            {
                cout<<1<<" "<<1<<" "<<a<<" "<<1<<endl;
            }
            else if (c==a&&d==1)
            {
                cout<<1<<" "<<b<<" "<<a<<" "<<1<<endl;
            }
            else if (c==a&&d==b)
            {
                cout<<1<<" "<<1<<" "<<a<<" "<<1<<endl;
            }
            else 
            {
                int cou1 = (c-1)+(d-1)+(a-c)+(b-d);
                int cou2 = (a-c)+(d-1)+(c-1)+(b-d);
                if (cou1>cou2) cout<<1<<" "<<a<<" "<<a<<" "<<b<<endl;
                else cout<<a<<" "<<1<<" "<<1<<" "<<b<<endl;
            }
        }
    }
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值