当前位置: 首页 > news >正文

个人工作室网站google云平台 wordpress

个人工作室网站,google云平台 wordpress,wordpress单栏,wordpress采集文章教程题意#xff1a; 给你n个数的序列#xff0c;当满足ijijij andandand aiaja_ia_jai​aj​时#xff0c;这两个点之间有一条边#xff0c;现在对点染色#xff0c;要求每个点相邻的点颜色不同#xff0c;问如何染色使得不同颜色数量最小。 题目…题意 给你n个数的序列当满足ijijij andandand aiaja_ia_jai​aj​时这两个点之间有一条边现在对点染色要求每个点相邻的点颜色不同问如何染色使得不同颜色数量最小。 题目 链接https://ac.nowcoder.com/acm/contest/17137/L 来源牛客网 Simone, a student of Graph Coloring University, is interested in permutation. Now she is given a permutation of length nn, and she finds that if she connects each inverse pair, she will get a graph. Formally, for the given permutation, if ijijij andandand aiaja_ia_jai​aj​, then there will be an undirected edge between node i and node j in the graph. Then she wants to color this graph. Please achieve poor Simone’s dream. To simplify the problem, you just need to find a way of coloring the vertices of the graph such that no two adjacent vertices are of the same color and minimize the number of colors used. 输入描述: There are multiple test cases. The first line of the input contains an integer T(1≤T≤106)T(1\leq T\leq 10^6)T(1≤T≤106) , indicating the number of test cases. For each test case, the first line contains an integer n(1≤n≤106)n(1 \leq n \leq 10^6)n(1≤n≤106), indicating the length of the permutation. The second line contains nn integers a1,a2,...,ana_1,a_2,...,a_na1​,a2​,...,an​ , indicating the permutation. It is guaranteed that the sum of nn over all test cases does not exceed 10610^6106 . 输出描述: For each test case, the first line contains an integer cc, the chromatic number(the minimal number of colors been used when coloring) of the graph. The second line contains nn integers c1,c2,...,cnc_1,c_2,...,c_nc1​,c2​,...,cn​ , the color of each node. Notice that cic_ici​ should satisfy the limit that 1≤ci≤c1 \leq c_i \leq c1≤ci​≤c If there are several answers, it is acceptable to print any of them. 示例1 输入 2 4 1 3 4 2 2 1 2 输出 2 1 1 1 2 1 1 1 分析 这道题在赛中时刚开始考虑是直接求每个元素的逆序对用树状数组然后该点颜色为逆序对数1交了wa了第一遍第二遍我们举出来了一个数据是 1 5 2 3 4结果是 1 4 1 1 1颜色数为4肯定不对所以进行了离散化交上去又wa了此时走入了瓶颈举了很多数据都是对的耽误了很多时间最后举了一个例子1 2 3 4 5 8 6 9 7按着思路应该是1 1 1 1 1 3 1 2 1但有更优解 1 1 1 1 1 2 1 2 1故此我们思路出问题了。讨论过后很短的时间就决定用线段树维护区间逆序对颜色最大值每次query得到最大值1即可。这里面有几个需要注意的点 序列从后往前遍历当我们对当前区间查找最大值时就是当前点逆序对的最大值因为某些虽然比当前点小但不为逆序对的值一定在序列的后面此时该点并没有赋值所以不需考虑。区间更新时因为少加了seg[u]max(seg[u1],seg[u1|1]);编译结果出现问题就像前面说的我们需要的是区间最大值直接套用模板就行不需要考虑逆序对之类的。最后每次更新颜色最大值输出即可orz%%%%%%一道签到题搞芥末久果然还是菜哈。 AC代码 #include bits/stdc.h using namespace std; typedef long long ll; const int N1e610; int n; int a[N],b[N]; int seg[N2]; void upd(int l,int t,int u,int L,int R){if(Ll Rl){seg[u]t;return;}int md(LR)1;if(lmd) upd(l,t,u1,L,md);if(lmd) upd(l,t,u1|1,md1,R);seg[u]max(seg[u1],seg[u1|1]); } int quy(int l,int r,int u,int L,int R){if(lL rR){return seg[u];}int md(LR)1;int tp0;if(lmd) tpmax(tp,quy(l,r,u1,L,md));if(rmd) tpmax(tp,quy(l,r,u1|1,md1,R));return tp; }int main() {int T;scanf(%d,T);while(T--){for(int i1; i4*n100; i) seg[i]0;scanf(%d,n);for(int i1; in; i){scanf(%d,a[i]);}int ma0;for(int in; i1; --i){b[i]quy(1,a[i],1,1,n)1;upd(a[i],b[i],1,1,n);mamax(ma,b[i]);}printf(%d\n,ma);for(int i1; in; i){printf(%d%c,b[i],(in?\n: ));}}return 0; }
http://www.pierceye.com/news/604477/

相关文章:

  • 给菠菜网站做外包免费做思维导图的网站
  • 网站建设服务哪家好如何做属于自己的网站
  • 正规的佛山网站建设公司网站空间怎么续费
  • 网站建设需要照片吗网站策划网站建设企业
  • 网站标签的作用北京医疗网站建设公司
  • 西部数码成品网站商务网站建设调研
  • 服装行业网站模板网页无法访问公司内网
  • 如何建设一个不备案的网站互联网的意思
  • 承德网站开发应聘软件开发工程师简历
  • 创意手机网站做go分析和kegg分析网站
  • 房地产开发建设网站wordpress多站点cdn
  • 医疗室内设计网站推荐wordpress htaccess
  • 织梦 图片网站源码uml电子商务网站建设文档
  • 商用图片的网站开发一款交友软件多少钱
  • 15年做哪些网站能致富单位做网站有哪些
  • 免费模板建站现在装宽带要多少钱
  • 泉州网站建设培训电商网站 支付宝接口
  • 国外网站素材公益广告设计图片
  • 个人做 网站2019电销助手app
  • 时尚网站网页设计公司想建立一个网站吗
  • 做竞价的网站wordpress还有什么
  • 单位建设网站用途硅胶鞋垫移动网站建设
  • 网站管理员招聘设计平台属性
  • 北票网站建设营销网站如何建设
  • 山东一建建设有限公司官方网站企业电子商务网站设计的原则
  • 江门网站制作培训学校做任务的阅币漫画网站
  • WordPress手机导航登陆代码重庆网站seo教程
  • 宁夏网站设计在哪里网站建设推广小王
  • 电子商务网站建设和维护公司网站可以免费建吗
  • storyset自定义插画网站wordpress 回复下载插件