Codeforces 174B【模拟构造】】的更多相关文章

本文作者:i春秋签约作家——rosectow 0×00前言 XSS又名叫CSS全程(cross site scriptting),中文名跨站脚本攻击,目前网站的常见漏洞之一,它的危害没有像上传漏洞,sql注入,命令执行,这种危害性极高的漏洞一样,但是大致xss与上面讲的这些漏洞不一样它是需要去被动式来完成攻击的,攻击者需要让管理员,用户等来配合完成攻击,xss它有三种语言编写,我们常见的是JavaScript ,比较少见的actionscript,VBScript,它们都是可以在html的标签中…
Codeforces 1041 E 构造题. 给出一种操作,对于一棵树,去掉它的一条边.那么这颗树被分成两个部分,两个部分的分别的最大值就是这次操作的答案. 现在给出一棵树所有操作的结果,问能不能构造这样一颗树,可以的话输出它. 反正就是看每个数出现了几次,然后形成一条链,从这个数开始,依次减小,链向N. 这样处理每个数,就行了. 中间一旦有冲突(不能形成链了),直接NO. #include <bits/stdc++.h> using namespace std; map<int,int…
题意: 给你一个串只有小写字母和点,让你构造前缀是1-8,后缀是1-3长度的文件名: 思路: 那么以"."作为分割点,把字符串都拿出来,然后 首段长度<=8 OK; 中间<=11 OK; 尾段<=3 OK; 否则都不行: 啊,水题啊,wa了一次,T了一次,神TM都是数据开小了, 一个是4e5写成5e4... 一个是不满足的情况可能会很长,才开了...25... #include <bits/stdc++.h> using namespace std; ty…
A. Neverending competitions time limit per test 2 seconds memory limit per test 512 megabytes input standard input output standard output There are literally dozens of snooker competitions held each year, and team Jinotega tries to attend them all (f…
C. Bear and Different Names time limit per test:1 second memory limit per test:256 megabytes input:standard input output:standard output In the army, it isn't easy to form a group of soldiers that will be effective on the battlefield. The communicati…
F. Restore a Number   Vasya decided to pass a very large integer n to Kate. First, he wrote that number as a string, then he appended to the right integer k — the number of digits in n. Magically, all the numbers were shuffled in arbitrary order whil…
C. Mike and gcd problem time limit per test: 2 seconds memory limit per test: 256 megabytes input: standard input output: standard output Mike has a sequence A = [a1, a2, ..., an] of length n. He considers the sequence B = [b1, b2, ..., bn] beautiful…
A #include <bits/stdc++.h> #define PI acos(-1.0) #define mem(a,b) memset((a),b,sizeof(a)) #define TS printf("!!!\n") #define pb push_back #define inf 0x3f3f3f3f //std::ios::sync_with_stdio(false); using namespace std; //priority_queue<i…
A. Crazy Computer time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output ZS the Coder is coding on a crazy computer. If you don't type in a word for a c consecutive seconds, everything you typed…
题意 https://vjudge.net/problem/CodeForces-1255D rxc的农场里'R'表示有米,现在有K只鸡,给这k只鸡选一些格子,每个鸡可以有多个格子(每个鸡至少吃一个米),但是每个鸡的格子必须连通.问吃到最多的米和最少的米的差最小是多少. 思路 如果农场一共有cnt个米,那么最优的分配肯定是差值为1或0,即给每个鸡先分cnt/k个米,然后把多余的分配给每个鸡.因为鸡的格子必须是连通的,所以可以考虑类似蛇形填数的方法,每找到cnt/k(多余的类似)个米就换下一只鸡,…
题意 https://vjudge.net/problem/CodeForces-1255C 一个长度为n的序列,给你n-2个三元组,比如p=[1,4,2,3,5],那么三元组为[1,4,2],[4,2,3],[2,3,5],其中每个三元组内的元素可以交换位置,整个三元组也可以和别的三元组整体交换位置,但不能交换不同三元组的数.求这个序列. 思路 记录每个数在所有三元组出现的次数.和每个数连了哪些数(和哪些数在一个三元组里),其中出现次数为1的肯定是序列的头或尾,因为序列可以反转(得到同样的三元…
Prison Transfer Time Limit: 1000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u Submit Status Description The prison of your city has n prisoners. As the prison can't accommodate all of them, the city mayor has decided to transfer c of t…
Marathon Time Limit: 1000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u Submit Status Description Valera takes part in the Berland Marathon. The marathon race starts at the stadium that can be represented on the plane as a square whose…
题目链接 \(Description\) 给定一个长为\(n\)的足迹序列(只包含\(L,R\)两种字符),你需要\(LRLRLR...\)这样交替在\(L\)和\(R\)上走(第一步可以选择\(L\)也可以选\(R\)).当你在\(L\)时,下一步可以走到任意一个没走过的\(R\):在\(R\)时,下一步可以走到任意一个没走过的\(L\).求走完这个\(L,R\)序列最少需要往回走几次,并输出方案(往回走是指从位置\(i\)走到位置\(j\),\(j\lt i\)).保证存在一组可行方案. \…
B. Checkpoints time limit per test:1 second memory limit per test:256 megabytes input:standard input output:standard output Vasya takes part in the orienteering competition. There are n checkpoints located along the line at coordinates x1, x2, ..., x…
https://codeforces.com/problemset/problem/474/D 这道题挺好的,思路是这样. 我们要找一个01串,其中0的段要被划分为若干个连续k的0. 我们设想一个长度为n的合法串是怎么被构造出来的,要么是上一个合法串后面直接连接1,要么是上一个合法串后面连接k个连续的0,那么每个0一一对应于一段连续的0. 所以dp[i]=dp[i-1]+dp[i-k]. 想出来就觉得不难了. #include<bits/stdc++.h> using namespace st…
题目链接:https://codeforces.com/contest/1368/problem/B 题意 构造最短的至少含有 $k$ 个 $codeforces$ 子序列的字符串. 题解 如下表:   c o d e f o r c e s 子序列个数 个数 1 1 1 1 1 1 1 1 1 1 $1^{10}$   2 2 2 2 2 2 2 2 2 2 $2^{10}$   3 3 3 3 3 3 3 3 3 3 $3^{10}$ 依次构造每个字符的个数即可. 证明   c o d e…
C. Team time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Now it's time of Olympiads. Vanya and Egor decided to make his own team to take part in a programming Olympiad. They've been best fri…
Valera and X Time Limit: 1000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u Submit Status Description Valera is a little boy. Yesterday he got a huge Math hometask at school, so Valera didn't have enough time to properly learn the Engli…
Inna and Alarm Clock Time Limit: 1000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u Submit Status Description Inna loves sleeping very much, so she needs n alarm clocks in total to wake up. Let's suppose that Inna's room is a 100 × 100 …
/* CF傻逼构造题 某人要经过n回合游戏,初始分值是2,等级为1. 每次有两种操作 1.无条件,分值加上自己的等级数. 2.当目前的数字是完全平方数并且该数字开方以后是等级数加1的整数倍,那么可以将分值开方,等价加一. 问:每个等级需要执行多少次第一种操作. 思路: 很显然每次要加到的那个数可以是相邻两个数的平方的积..但是考虑到最后这样刚好会超long long... 但是我们最终也不要求求这个数是多少,我们需要知道它除以i是多少... */ #include<bits/stdc++.h>…
题意: 给你k件衣服处理,告诉你洗衣机烘干机折叠机的数量,和它们处理一件衣服的时间,要求一件衣服在洗完之后必须立刻烘干,烘干之后必须立刻折叠,问所需的最小时间. 思路: 1.按照时间模拟 2.若洗完的衣服或者烘干的衣服较多来不及进行下一个步骤,则从一开始就顺延洗衣服的时间,贪心的思想也是体现在这里. 3.关键在于烘干衣服的顺延如何处理,因为需要调整洗衣服的起始时间,其实我们只要对烘干衣服的时间进行顺延处理就可以了,因为即使没有调整洗衣服的起始时间,那么下次到了烘干衣服的时间的时候因为烘干衣服的数…
思路:模拟移动即可,如果球落入洞中停止移动.注意:有可能第一个位置就是洞!! AC代码 #include <cstdio> #include <cmath> #include <cctype> #include <algorithm> #include <cstring> #include <utility> #include <string> #include <iostream> #include <…
https://vjudge.net/problem/CodeForces-864C 题意:两地之间有个加油站,往返走k个单程,最少加油多少次. 大佬几十行代码就解决,我却要用一百多行的if语句模拟解决. #include<stdio.h> #include<iostream> #include<algorithm> #include<cstring> #include<math.h> #include<string> #includ…
Polycarp invited all his friends to the tea party to celebrate the holiday. He has ncups, one for each of his n friends, with volumes a1, a2, ..., an. His teapot stores wmilliliters of tea (w ≤ a1 + a2 + ... + an). Polycarp wants to pour tea in cups…
大意:构造n结点树, 高度$i$的结点有$a_i$个, 且叶子有k个. 先确定主链, 然后贪心放其余节点. #include <iostream> #include <algorithm> #include <cstdio> #include <math.h> #include <set> #include <map> #include <queue> #include <string> #include &l…
大意: 求构造一棵树, 每个节点回答它的祖先个数, 求最少打错次数. 挺简单的一个构造, 祖先个数等价于节点深度, 所以只需要确定一个最大深度然后贪心即可. 需要特判一下根的深度, 再特判一下只有一个结点的情况 #include <iostream> #include <algorithm> #include <cstdio> #include <math.h> #include <set> #include <map> #inclu…
http://codeforces.com/contest/1004/problem/D 题意:网格图给定到中心点的曼哈顿距离数组, 求该图n,m及中心点位置 首先可以观察到距离最大值mx一定在某个角上, 可将它调整到位置(n,m) 设中心点(x, y) 则可以得到 n-x+m-y=mx 再注意到假若图无限大, 则对每个距离d的取值一定有4*d个 即第一个取值数<4*d的d可以调整为中心点的x坐标 然后就可以暴力枚举因子判断了 #include <iostream>#include &l…
题意: 就是让构造一个直径为d的树  每个结点的度数不能超过k 解析: 先构造出一条直径为d的树枝 然后去遍历这条树枝上的每个点  为每个点在不超过度数和直径的条件下添加子嗣即可 #include <bits/stdc++.h> #define mem(a, b) memset(a, b, sizeof(a)) using namespace std; , INF = 0x7fffffff; int n, d, k; int cnt; struct node { int u, v; node(…
大意: 求构造n个pair, 每个pair满足 对于每k组, 让$b_i$为$[1,k]$, $g_i$循环右移就好了 int n, k, cnt; int main() { scanf("%d%d", &n, &k); if (n>(ll)k*(k-1)) return puts("NO"),0; puts("YES"); int cnt = 0; REP(i,1,n) { int cur = i+1; REP(j,1,k…