CodeForces 631C Print Check】的更多相关文章

排序+构造+预处理 #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…
题目链接 Print Check 注意到行数加列数最大值只有几千,那么有效的操作数只有几千,那么把这些有效的操作求出来依次模拟就可以了. #include <bits/stdc++.h> using namespace std; #define rep(i,a,b) for(int i(a); i <= (b); ++i) + ; + ; struct node{ int op, x, y; } a[N]; int col[Q][Q]; int v[N]; //v[i] = 1 则第i个…
对于每一个格子,看是行最后画还是列最后画.预处理一下就可以了. #include<stdio.h> #include<string.h> int n,m,k; +]; +]; +]; +]; int main() { scanf("%d%d%d",&n,&m,&k); memset(high,-,sizeof high); ;i<=k;i++) scanf("%d%d%d",&op[i],&id[…
题意: 按顺序给定列和行进行涂色,输出最终得到的方格颜色分布. 分析: 记录下涂的次序,如果某个元素的横和列都被涂过,那么就选择次序最大的颜色. 代码: #include<iostream> #include<cstdio> using namespace std; const int maxn = 5005; int num[maxn][maxn]; int ma[2][maxn]; int ro[maxn], ca[maxn]; int main (void) { int n,…
B. Print Check 题目连接: http://www.codeforces.com/contest/631/problem/B Description Kris works in a large company "Blake Technologies". As a best engineer of the company he was assigned a task to develop a printer that will be able to print horizon…
B. Print Check time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Kris works in a large company "Blake Technologies". As a best engineer of the company he was assigned a task to develop a…
B. Print Check time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Kris works in a large company "Blake Technologies". As a best engineer of the company he was assigned a task to develop a…
B. Print Check time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output Kris works in a large company "Blake Technologies". As a best engineer of the company he was assigned a task to develop a pri…
连接:Print Check 题意:n行m列的矩阵,有k次涂色,每一涂一行或者一列,求最后的涂色结果. 从数据的大小看,暴力肯定要TLE: 问题是如何存储数据. 首先:我们只要最后的涂色结果. 其次:没有必要用for每个数据涂一遍. 所以如果能一次直接涂一行就可以了: #include <iostream> #include <cstdio> uising namespace std; #define N 5005 ; typedef long long LL; int row[N…
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…
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…
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…
https://codeforces.com/contest/1202/problem/D 当时想的构造是中间两个3,然后前后的1和7组合出n,问题就是n假如是有一个比较大的质数因子或者它本身就是质数就会超长度.事实上程序会正确执行并分解成两个超大质数,不断putchar导致TLE. 正确的做法是通过3来主要组成答案,考虑133..337,中间有x个3,则有C(x,2)个组合,很明显可以发现在x=45000附近超过1e9的上限,而剩下的余数不会超过x=45000(或者在这个附近?). 考虑怎么添…
题意:给定n和m. 给定一个长度为n的序列,m次操作. 接下来m次操作,每行第一个数若为1,则增序排列,若为2则降序排列,第二个数是排列的范围,即从第一个数排序到第某个数. 思路: 首先,对于其中范围最大的操作和其右方范围次大的操作之间有一个区间,我们可以知道这个区间的序列是按照范围最大的操作的序列进行的,因为右边不会有新的操作,左边的操作会被这次范围最大的操作取代.同理,向右边不断寻找最大的操作,然后能确定和其右边次大的操作之间的差值的区间的序列的顺序. 如果是增序,那么在确定差值区间的每个元…
题目链接 按题目给出的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…
题目链接 题目大意:给定序列, 给定若干操作, 每次操作将$[1,r]$元素升序或降序排列, 求操作完序列 首先可以发现对最后结果有影响的序列$r$一定非增, 并且是升序降序交替的 可以用单调栈维护这些序列, 再考虑最后如何通过这些序列恢复数组 因为序列是升降交替的, 保存一个排序好的序列, 每次从两端取出元素添加即可 #include <iostream> #include <algorithm> #include <cstdio> #include <vect…
题意: 给定序列,将前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规定的排序的,并且不会…
主题链接:点击打开链接 意甲冠军: 特定2弦 选择中删除一个字符串的第一个字母,得2个字符串全然同样 问哪些位置能够选 思路: hash求前缀后缀.然后枚举位置 #include <cstdio> #include <algorithm> #include<iostream> #include<string.h> #include <math.h> #include<queue> #include<map> #includ…
A /* Huyyt */ #include <bits/stdc++.h> #define mem(a,b) memset(a,b,sizeof(a)) #define mkp(a,b) make_pair(a,b) #define pb push_back using namespace std; typedef long long ll; ; ; ]; int main() { int n; cin >> n; ;i<=n;i++) { cin >> num…
题面传送门 解决思路: 首先考虑到,一个点最终的情况只有三种可能:不被染色,被行染色,被列染色. 若一个点同时被行.列染色多次,显示出的是最后一次被染色的结果.所以我们可以使用结构体,对每一行.每一列记录下其最后一次被染色的颜色和时间.因为同行或同列反复染只有最后一次有影响,所以后来的直接覆盖之前的即可. 一个点的最终结果:若最后一次染行晚于最后一次染列,则显示最后一次染行的颜色,反之显示最后一次染列的颜色. 然后程序就很简单了. AC Code: #include<bits/stdc++.h>…
Codeforces #344 Div.2 Interview 题目描述:求两个序列的子序列或操作的和的最大值 solution 签到题 时间复杂度:\(O(n^2)\) Print Check 题目描述:有一个棋盘,对其进行染色,每次染一行或一列,后来的颜色会覆盖原来的颜色,输出最后的棋盘. solution 题解用二维线段树,其实可以不用. 对染色进行离线操作,那么染过的格子.行.列就不用再染了.所以每个格子可以记录四个指针,分别是行前驱,行后继,列前驱列后继,染色时按照这个跳着来染就好了.…
水 A - Interview 注意是或不是异或 #include <bits/stdc++.h> int a[1005], b[1005]; int main() { int n; scanf ("%d", &n); for (int i=0; i<n; ++i) { scanf ("%d", a+i); } for (int i=0; i<n; ++i) { scanf ("%d", b+i); } int a…
A. Cutting Banner time limit per test:2 seconds memory limit per test:256 megabytes input:standard input output:standard output A large banner with word CODEFORCES was ordered for the 1000-th onsite round of Codeforcesω that takes place on the Miami…
A. Cutting Banner time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output A large banner with word CODEFORCES was ordered for the 1000-th onsite round of Codeforcesω that takes place on the Miami…
A:二分答案,从左往右考虑每个人,选尽量靠左的钥匙即可. #include<iostream> #include<cstdio> #include<cmath> #include<cstdlib> #include<cstring> #include<algorithm> using namespace std; #define ll long long #define int long long #define N 2010 #de…
A. Cutting Banner Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/538/problem/A Description A large banner with word CODEFORCES was ordered for the 1000-th onsite round of Codeforcesω that takes place on the Miami beach. Un…
B. Print Check time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Kris works in a large company "Blake Technologies". As a best engineer of the company he was assigned a task to develop a…
  A. Cutting Banner   time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output A large banner with word CODEFORCES was ordered for the 1000-th onsite round of Codeforcesω that takes place on the Mi…
Print Check CodeForces - 631B Kris works in a large company "Blake Technologies". As a best engineer of the company he was assigned a task to develop a printer that will be able to print horizontal and vertical strips. First prototype is already…