原题链接 题目大意:一道类似于简单图像压缩的题目.给定一个调色板,然后把24位真彩色按照就近原则聚类. 解法:每个像素的色彩都是RGB三个值,相当于三维空间的一个点.所以当一个新的像素进来时,分别和调色板中的每一个颜色求欧式距离,距离最近的那个点就是应该归属的那个类. 参考代码: #include<stdio.h> #include<math.h> #define R 0 #define G 1 #define B 2 int target[16][3]; int main(){…
输入一组RGB颜色列表,每行一个颜色,是三个从0~255的整数 前16行是目标颜色组,-1 -1 -1表示结束 16组颜色以后接下来的几行是需要判断的,看它和哪个颜色的距离D最小,找出这个对应的颜色 注意空格括弧等等 #include<iostream> #include<math.h> using namespace std; struct Color { int R,G,B; }map[]; int main(void) { int i,r,g,b,mr,mg,mb…
Color the Ball Time Limit: 2 Seconds Memory Limit: 65536 KB There are infinite balls in a line (numbered 1 2 3 ....), and initially all of them are paint black. Now Jim use a brush paint the balls, every time give two integers a b and follow by…
题意:有从 1 开始递增依次编号的很多球,开始他们都是黑色的,现在依次给出 n 个操作(ai,bi,ci),每个操作都是把编号 ai 到 bi 区间内 的-所有球涂成 ci 表示的颜色(黑 or 白),然后经过 n 次给定的操作后,求最长的连续白色区间的左端点和右端点. 析:由于数比较大,可以先进行离散化,然后是区间更新,最后还循环暴力一次,单点求值. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #incl…
描述Painting some colored segments on a line, some previously painted segments may be covered by some the subsequent ones.Your task is counting the segments of different colors you can see at last. InputThe first line of each data set contains exactly…
Color the Ball Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 3502 Accepted Submission(s): 863 Problem DescriptionThere are infinite balls in a line (numbered 1 2 3 ....), and initially all…