• CF763B Timofey and Rectangles


    题目戳这里

    首先答案肯定是YES,因为一个平面图肯定可以被4种颜色染色,关键是怎么输出方案。
    由于4是一个特殊的数字(4 = 2^2),而我们还有一个条件就是边长为奇数,而奇数是会改变二进制位的。

    接下来我们这样思考,对于每个矩形我们设其左下角坐标为((x,y)),我们把他染成((x;mod;2) imes2+(y;mod;2))。由于边长是奇数,所以相邻矩形二进制位至少有一位不一样。然后这题就做完了。

    #include<iostream>
    #include<cstdio>
    #include<cstdlib>
    using namespace std;
    
    int N;
    
    inline int gi()
    {
    	char ch; int ret = 0,f = 1;
    	do ch = getchar(); while (!(ch >= '0'&&ch <= '9')&&ch != '-');
    	if (ch == '-') f = -1,ch = getchar();
    	do ret = ret*10+ch-'0',ch = getchar(); while (ch >= '0'&&ch <= '9');
    	return ret*f;
    }
    
    int main()
    {
    	freopen("763B.in","r",stdin);
    	freopen("763B.out","w",stdout);
    	puts("YES");
    	for (N = gi();N--;)
    	{
    		int X1 = gi(),Y1 = gi(),X2 = gi(),Y2 = gi();
    		if (X1 > X2) swap(X1,X2);
    		if (Y1 > Y2) swap(Y1,Y2);
    		printf("%d
    ",(((X1&1)<<1)|(Y1&1))+1);
    	}
    	fclose(stdin); fclose(stdout);
    	return 0;
    }
    
  • 相关阅读:
    Ansible概述
    iptables端口转发
    iptables配置实例
    iptables常用操作
    iptables常用命令
    每日总结3.15
    每日总结3.12
    每日总结3.11
    每日总结3.10
    每日总结3.9
  • 原文地址:https://www.cnblogs.com/mmlz/p/6441225.html
Copyright © 2020-2023  润新知