D. Timofey and rectangles[四色定理]

D. Timofey and rectangles

关于四色定理, 和歌德巴赫猜想/ 费马大定理 为数学3大数学 猜想 之一,由某大学生提出

题意:给n个矩形的坐下角坐标和右上角坐标.问如何染色(四种颜色),使得相邻矩形颜色不同

思路: 一定有解

1) 对左下角坐标进行讨论


坐标颜色(任意一种排序)
奇偶1
偶奇2
偶偶3
奇奇4

如果左下角为奇偶,那么左下角还是奇偶的就一定不会和这个矩形相邻(画图证明四个角的坐标奇偶性)

#include<bits/stdc++.h>
#define PI acos(-1.0)
#define pb push_back
#define F first
#define S second
#define debug puts
#define setp cout << fixed << setprecision(15)
#define FAST_IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
typedef long long ll;
const int N=2e3+3;
const int MOD=998244373;
//ll rain[N],dp[N],u[N];
int main(void){
    FAST_IO;
//    cout << -1%2 << endl;
    int n;
    cin >> n;
    cout <<"YES"<<endl;
    for(int i=1;i<=n;i++){
        int a,b,c,d;
        cin >>a >> b >> c >> d;
        if(a<0) a=-a;
        if(b<0) b=-b;
        if(c<0) c=-c;
        if(d<0) d=-d;
        if(a%2==1&&b%2==1)  cout << 1 << endl;
        else if(a%2==1&&b%2==0)  cout << 2 << endl;
        else if(a%2==0&&b%2==0)  cout << 3 << endl;
        else if(a%2==0&&b%2==1)  cout << 4 << endl;
    }

    return 0;
}
/********
50267
*********/

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值