四色定理 :将平面任意地细分为不相重叠的区域,每一个区域总可以用1234这四个数字之一来标记而不会使相邻的两个区域得到相同的数字。”这里所指的相邻区域是指有一整段边界是公共的。如果两个区域只相遇于一点或有限多点就不叫相邻的。因为用相同的颜色给它们着色不会引起混淆。
小数据的话,可以直接dfs染色
但是这题大数据 ,就需要观察
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
#include <string>
#include <map>
#include <vector>
using namespace std;
typedef long long ll;
int main()
{
int n,a,b;
scanf("%d",&n);
puts("YES");
for(int i=0;i<n;i++)
{
scanf("%d%d%*d%*d",&a,&b);
printf("%d\n",(!(a&1))?((!(b&1))?3:4):((a&1)+(b&1)));
}
}

本文介绍四色定理的基本概念及其在图论中的应用,通过一个具体的编程实例展示如何使用简单的算法实现地图区域的有效染色,避免相邻区域获得相同颜色。
2844

被折叠的 条评论
为什么被折叠?



