CF370A-Rook, Bishop and King

CF370A-Rook, Bishop and King

题目大意

国际象棋棋盘上有两个位置,现在问一个车,象和王,从一个位置走到另一个位置的最少移动次数。

题解

对于所有,如果两个点重合,则都为 \(0\)

对于车,如果同行同列则为 \(1\) 。否则为 \(2\)

对于象,特殊的,横纵坐标和奇偶性不同则无法到达输出 \(0\) 。如果在统一斜线或反斜线则为 \(1\) ,否则为 \(2\)

对于王,取 \(max(|x1-x2|,|y1-y2|)\)

#include<bits/stdc++.h>
#define ios ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define umap unordered_map
#define endl '\n'
using namespace std;
using i128 = __int128;
const int mod =1e9+7;
template <typename T>void read(T&x){
    x=0;int f = 1;
    char c=getchar();
    for(;!isdigit(c);c=getchar())if(c=='-')f=-1;
    for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+(c^48);
    x*=f;
}
template <typename T>void print(T x) {
     if (x < 0) { putchar('-'); x = -x; }
     if (x > 9) print(x / 10);
     putchar(x % 10 + '0');
}
#define int long long
const int N=500005;
const int M=2000005;
inline void solve()
{
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if(a==c&&b==d)
	{
		cout<<"0 0 0"<<endl;
		return;
	}
	
	if(a==c||b==d)
	{
		cout<<1<<" ";
	}
	else
	{
		cout<<2<<" ";
	}
	
	if((a+b)%2!=(c+d)%2)
	{
		cout<<0<<" ";
	}
	else if(a-b==c-d||a+b==c+d)
	{
		cout<<1<<" ";
	}
	else
	{
		cout<<2<<" ";
	}
	
	cout<<max(abs(a-c),abs(b-d))<<endl;
	
}

signed main()
{
	ios;
	int T=1;
//	cin>>T;
	for(;T--;) solve();
	return 0;
}
posted @ 2025-11-25 22:15  NDAKJin  阅读(0)  评论(0)    收藏  举报