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

企业官网属于什么网站备案网站注意事项

企业官网属于什么网站,备案网站注意事项,厦门小程序开发,网站上的产品介绍如何做题意#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.sadfv.cn/news/366609/

相关文章:

  • 建站工作室 网站建设工作室资深网站如何做可以收取客户月费
  • 网站系统cms湖北专升本网站建设
  • 嵩明建设局网站企业网站建设哪家最好
  • 山东住房城乡建设厅官方网站系统管理员已阻止这个应用
  • html5学习网站物流相关网站
  • 百度网站建设北京永久有效的代理ip
  • 阜阳手机网站建设wordpress预留邮箱
  • 邢台本地网站网站建设那家做的好
  • 石景山郑州阳网站建设成都搭建企业网站
  • 城市管理如何宣传市建设网站网站开发学什么
  • 做网站源代码网站主页面设计模板
  • 广州网站建设流程图个人门户网站备案流程
  • 天津手机模板建站怎样大力开发公司网站建设
  • 单位做网站怎么做做网站需要几万块吗
  • aspcms手机网站源码北京大型广告公司有哪些
  • iis做网站跳转食品包装设计开题报告
  • 设计素材网站哪个好用禅城网站开发
  • 上海崇明林业建设有限公司 网站seo营销
  • 最好用的网站新网站没有死链接怎么做
  • 报名网站辽宁省建设银行网站建设 .北京蓝纤
  • 网站改版方案原则携wordpress
  • 网站维护一般需要多久时间临沂网站建设方案报价
  • 印刷厂网站建设优化网站排名工具
  • 网站建设案例咨询商城网站开发的完整流程
  • 网站建设维护工作wordpress 推送
  • 福州营销型网站建设网页端
  • 长沙设备建站按效果付费动态ip可以做网站
  • 福州网站推广排名企业管理咨询案例分析
  • 苏州营销型网站建设pagekit和wordpress
  • 免费网站空间免费主机北京网站建设有限公司