codeforces 631C. Report】的更多相关文章

C. Report time limit per test:2 seconds memory limit per test:256 megabytes input:standard input output:standard output Each month Blake gets the report containing main economic indicators of the company "Blake Technologies". There are n commodi…
题目链接 按题目给出的r, 维护一个递减的数列,然后在末尾补一个0. 比如样例给出的 4 21 2 4 32 31 2 递减的数列就是3 2 0, 操作的时候, 先变[3, 2), 然后变[2, 0), 具体的过程看代码.   #include <iostream> #include <vector> #include <cstdio> #include <cstring> #include <algorithm> #include <cm…
题意: 给定序列,将前a个数进行逆序或正序排列,多次操作后,求最终得到的序列. 分析: 仔细分析可以想到j<i,且rj小于ri的操作是没有意义的,对于每个i把类似j的操作删去(这里可以用multiset或者直接模拟栈的操作),最后我们会获得一个严格下降的序列即ri>rj && i<j,并且相邻的t不相等. 那么对于ri,ri+1,对[0,ri)进行排序后,又对其子序列[0,ri+1)进行相反的排序,其实只有区间[ri+1,ri−1]]内的数是按照ti规定的排序的,并且不会…
C. Report time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Each month Blake gets the report containing main economic indicators of the company "Blake Technologies". There are n commodi…
题目链接 题目大意:给定序列, 给定若干操作, 每次操作将$[1,r]$元素升序或降序排列, 求操作完序列 首先可以发现对最后结果有影响的序列$r$一定非增, 并且是升序降序交替的 可以用单调栈维护这些序列, 再考虑最后如何通过这些序列恢复数组 因为序列是升降交替的, 保存一个排序好的序列, 每次从两端取出元素添加即可 #include <iostream> #include <algorithm> #include <cstdio> #include <vect…
C. Report time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Each month Blake gets the report containing main economic indicators of the company "Blake Technologies". There are n commodi…
Each month Blake gets the report containing main economic indicators of the company "Blake Technologies". There are n commodities produced by the company. For each of them there is exactly one integer in the final report, that denotes correspond…
Each month Blake gets the report containing main economic indicators of the company "Blake Technologies". There are n commodities produced by the company. For each of them there is exactly one integer in the final report, that denotes correspond…
题意:给定n和m. 给定一个长度为n的序列,m次操作. 接下来m次操作,每行第一个数若为1,则增序排列,若为2则降序排列,第二个数是排列的范围,即从第一个数排序到第某个数. 思路: 首先,对于其中范围最大的操作和其右方范围次大的操作之间有一个区间,我们可以知道这个区间的序列是按照范围最大的操作的序列进行的,因为右边不会有新的操作,左边的操作会被这次范围最大的操作取代.同理,向右边不断寻找最大的操作,然后能确定和其右边次大的操作之间的差值的区间的序列的顺序. 如果是增序,那么在确定差值区间的每个元…
排序+构造+预处理 #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> using namespace std; + ; int n, m; int a[maxn], ans[maxn]; int op[maxn], e[maxn]; int pos[maxn]; int first, last; int flag; int p; int tot; bool cmp(c…
目录: 1.1093D. Beautiful Graph(DFS染色) 2.514C - Watto and Mechanism(Tire) 3.69E.Subsegments(STL) 4.25C. Roads in Berland(最短路松弛操作) 5.128B. String Problem (floyd预处理) 6.33C.Wonderful Randomized Sum(思维) 7.1292B.Aroma's Search (暴力+思维) 8.1286 A.Garland(DP) 9.…
C. Report 题目连接: http://www.codeforces.com/contest/631/problem/C Description Each month Blake gets the report containing main economic indicators of the company "Blake Technologies". There are n commodities produced by the company. For each of th…
Report 题意:给长度为n的序列,操作次数为m:n and m (1 ≤ n, m ≤ 200 000) ,操作分为t r,当t = 1时表示将[1,r]序列按非递减排序,t = 2时表示将序列[1,r]按非递增排序:输出m次操作后的序列? 思路:由于排序是前缀排序,那么前面的操作ti,ri;如果 ri <= rj;那么第i次操作直接被覆盖了.这样我们可以知道有用的排序操作ri是按照严格递减的:并且这时在ri 与r(i + 1)之间的数与后面的操作无关了~~(线性处理),这就直接说明了只需要…
Summer Practice Report dp[ i ][ 0 ]表示放完前 i 页, 第 i 页最后一段是 0, 0个数的最小值. dp[ i ][ 1 ]表示放完前 i 页, 第 i 页最后一段是 1, 1个数的最小值. 这个转移细节有点多... #include<bits/stdc++.h> #define LL long long #define LD long double #define fi first #define se second #define mk make_pa…
题目链接: D. Robot Rapping Results Report time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output While Farmer John rebuilds his farm in an unfamiliar portion of Bovinia, Bessie is out trying some alt…
题目链接: http://codeforces.com/problemset/problem/645/D 题意: 给定n个机器人的m个能力大小关系,问你至少要前几个大小关系就可以得到所有机器人的能力顺序. 分析: 拓扑+二分. 注意最终的顺序不能缺点,先把度为0的点入队,如果度为0的点的个数大于1,则说明至少有两个点的能力大小不确定,无法继续. 代码: #include<bits/stdc++.h> using namespace std; const int maxn = 100005; v…
C. Report time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output Each month Blake gets the report containing main economic indicators of the company "Blake Technologies". There are n commodities…
题目链接 我们可以发现, 这是一个很明显的二分+拓扑排序.... 如何判断根据当前的点, 是否能构造出来一个唯一的拓扑序列呢. 如果有的点没有出现, 那么一定不满足. 如果在加进队列的时候, 同时加了两个点, 也就是队列的size > 1, 那么也不满足. 如果队列空了之后, 还有的点没有操作过, 那么同样不满足. 然后就没有了 #include <iostream> #include <vector> #include <cstdio> #include <…
二分,拓扑排序. 二分答案,然后进行拓扑排序检查,若某次发现存在两个或者两个以上入度为$0$的节点,那么不可行. #pragma comment(linker, "/STACK:1024000000,1024000000") #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> #include<vector> #include<ma…
While Farmer John rebuilds his farm in an unfamiliar portion of Bovinia, Bessie is out trying some alternative jobs. In her new gig as a reporter, Bessie needs to know about programming competition results as quickly as possible. When she covers the…
C. Drazil and Park 题目连接: http://codeforces.com/contest/516/problem/C Description Drazil is a monkey. He lives in a circular park. There are n trees around the park. The distance between the i-th tree and (i + 1)-st trees is di, the distance between t…
G. FacePalm Accounting Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100513/problem/G Description An owner of a small company FacePalm has recently learned that the city authorities plan to offer to small businesses to partic…
G. FacePalm Accounting Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100513/problem/G Description An owner of a small company FacePalm has recently learned that the city authorities plan to offer to small businesses to partic…
Codeforces #344 Div.2 Interview 题目描述:求两个序列的子序列或操作的和的最大值 solution 签到题 时间复杂度:\(O(n^2)\) Print Check 题目描述:有一个棋盘,对其进行染色,每次染一行或一列,后来的颜色会覆盖原来的颜色,输出最后的棋盘. solution 题解用二维线段树,其实可以不用. 对染色进行离线操作,那么染过的格子.行.列就不用再染了.所以每个格子可以记录四个指针,分别是行前驱,行后继,列前驱列后继,染色时按照这个跳着来染就好了.…
2018-03-03 http://codeforces.com/problemset/problem/937/B B. Vile Grasshoppers time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output The weather is fine today and hence it's high time to climb th…
A. Is it rated? time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Is it rated? Here it is. The Ultimate Question of Competitive Programming, Codeforces, and Everything. And you are here to a…
D. Robot Rapping Results Report 题目连接: http://www.codeforces.com/contest/655/problem/D Description While Farmer John rebuilds his farm in an unfamiliar portion of Bovinia, Bessie is out trying some alternative jobs. In her new gig as a reporter, Bessi…
地址:http://codeforces.com/contest/807/problem/D 题目: D. Dynamic Problem Scoring time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Vasya and Petya take part in a Codeforces round. The round las…
地址:http://codeforces.com/contest/782/problem/D 题目: D. Innokenty and a Football League time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Innokenty is a president of a new football league in B…
Ballot Analyzing Device 题目连接: http://codeforces.com/gym/100269/attachments Description Election committee of Flatland is preparing for presidential elections. To minimize human factor in ballot counting they decided to develop an automated Ballot Ana…