Codeforces #564div2 C(模拟)】的更多相关文章

要点 没想到的一点是,对于堆里的某牌,最好情况是它出来时后边都准备就绪了,答案是\(p[i] + (n - i + 1)\),所有的这个取最大的即可 一发结束的情况先特判一下 const int maxn = 2e5 + 5; int n, pos, ans; int a[maxn], b[maxn], In[maxn], p[maxn]; int main() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); cin >> n;…
Fox and Cross Time Limit: 1000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u Submit Status Description Fox Ciel has a board with n rows and n columns. So, the board consists of n × n cells. Each cell contains either a symbol '.', or a s…
Rebranding Problem Description The name of one small but proud corporation consists of n lowercase English letters. The Corporation has decided to try rebranding - an active marketing strategy, that includes a set of measures to change either the bra…
B. Cards time limit per test:2 seconds memory limit per test:256 megabytes input:standard input output:standard output Catherine has a deck of n cards, each of which is either red, green, or blue. As long as there are at least two cards left, she can…
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…
B. Barnicle time limit per test: 1 second memory limit per test :256 megabytes input: standard input output: standard output Barney is standing in a bar and starring at a pretty girl. He wants to shoot her with his heart arrow but he needs to know th…
活生生打成了大模拟... #include <bits/stdc++.h> using namespace std; typedef long long LL; typedef unsigned long long ULL; typedef pair<int,int>PII; const double eps=1e-5; const double pi=acos(-1.0); //const int mod=1e9+7; const int INF=0x3f3f3f3f; //ht…
题目链接:http://codeforces.com/problemset/problem/719/C 题目大意: 留坑...…
题意:给定三个操作,1,是x应用产生一个通知,2,是把所有x的通知读完,3,是把前x个通知读完,问你每次操作后未读的通知. 析:这个题数据有点大,但可以用STL中的队列和set来模拟这个过程用q来标记是哪个应用产生的,用set来记录是第几个通知. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio> #include <string> #include &l…
强行模拟 纪念一下…… #include<stdio.h> #include<iostream> #include<algorithm> #include<math.h> #include<string.h> #include<string> #include<map> #include<vector> #include<queue> #define M(a,b) memset(a,b,sizeof…
题目大意:给出n个点的坐标,和你当前的坐标,求走过n-1个点的最短路程. 题目思路:走过n-1个点,为了使路程更短,那么不走的点只可能第一个点或最后一个点.模拟就行了,比较恶心. #include<iostream> #include<algorithm> #include<cstring> #include<vector> #include<stdio.h> #include<stdlib.h> #include<queue&…
A. Snacktower time limit per test:2 seconds memory limit per test:256 megabytes input:standard input output:standard output According to an old legeng, a long time ago Ankh-Morpork residents did something wrong to miss Fortune, and she cursed them. S…
贪心策略: 1.只有一个最大值,选着第二大的一起参加比赛减分. 2.有奇数个最大值,选择三个进行比赛. 3.偶数个最大值,选择两个进行比赛. 为什么不把最大值全部选择? 因为最多只能选五个,有可能选择完五个只剩下一个最大值,那么就会进行贪心策略1,会出错. AC代码: #include<cstdio> #include<set> using namespace std; const int maxn=1e4+1; char ans[maxn][101]; int cnt=0,n;…
C. Voting time limit per test: 1 second memory limit per test: 256 megabytes input: standard input output: standard output There are n employees in Alternative Cake Manufacturing (ACM). They are now voting on some very important question and the lead…
题意:给你一个01串,问其是否能拆成若干形如0101010的子串,若能,输出所有子串的0,1 的位置. 题解:一开是暴力,然后瞎找规律, 最后找到一种神奇的线性构造法:扫一遍字符串,若为0就一直竖着往下写0,碰到1就回头往上写,再碰到0 就回头往下写······判断无法构造的依据:如果写1写得超过了上界就跳出,如果最后写的0不在最下面也跳出//codeforces上看到的一段代码秀的脑壳疼 坑:之前随便找规律,写了个巨丑的代码,逻辑混乱,直接wa掉. 无脑写的直接T了 ac #define _C…
大意: 给定$n$元素序列$a$, 求将$a$划分为连续的等差数列, 且划分数尽量小. $a$中的$-1$表示可以替换为任意正整数, 等差数列中必须也都是正整数. 贪心策略就是从前到后尽量添进一个等差数列中, 否则就再新增一个等差数列. 这种模拟题最好还是写个递归, 思路会清晰一些 #include <iostream> #include <algorithm> #include <cstdio> #define PER(i,a,n) for(int i=n;i>…
C. Recycling Bottles time limit per test: 2 seconds memory limit per test: 256 megabytes input: standard input output: standard output It was recycling day in Kekoland. To celebrate it Adil and Bera went to Central Perk where they can take bottles fr…
遇见模拟题 有两种做法 例如这题: 1.直接去算次数(统计哪个数在第几位,然后去运算) 2.模拟操作 贴一个别人的代码...https://blog.csdn.net/weixin_39453270/article/details/80548780 #include <bits/stdc++.h> using namespace std; const int INF=0x3f3f3f3f; string str1,str2; ; void Get(char a,char b,int n,int…
思路: 枚举0-9之间的数,然后判断. 然后一鼓作气打成了大模拟....我日啊... 心疼自己. #include <bits/stdc++.h> using namespace std; typedef long long LL; const int N=1e4+10; int n,k; char s[N],ss[N]; int num[19]; int cnt[19],len; int all[N][15]; void solve(int x) { int sum; for(int i=0…
坑点 不记它难解我心头之恨-- WA1:不要读错题Orz,顺序是按它给定的.那就是个类似栈的东西,重点在于输出. 然而我输出很快就模拟对了-- WA2:数据:1 int.我日了不看数据我真的去de模拟的bug了. WA3:中间栈空是非法. 貌似建一棵树可以迅速搞掉--擦 #include <cstdio> #include <cstring> #include <iostream> #include <string> #include <vector&…
题意: 给一个字符串代表相邻学生的比较,L代表左边多,R表示右边多,=表示左右相等. 保证每个人拿糖>=1,在分糖最少的情况下,输出每个学生所分得的糖. 思路: 模拟一下,第一个人一开始拿1个,然后模拟下去,如果是=,那就=前面的,如果是R,那就比前面的多一个,如果是L,最好的情况就是拿1个,但是有可能前面那个也是1,那么就往前更新,如果符号是=,前面那个等于现在的,如果是R,那么直接跳出,不用往前更新了,因为顺序的更新本身就比之前的大了,如果是L只要判断一下前面的是不是和当前的相等,是的话,前…
题意: 查询数 和 最大的队列容量+1: 按时间顺序 ti代表,第i个出线的时间: di代表,第i个需要处理的时间: 对于第i个输出他所需要的时间完成,或者拒绝进入输出-1: 思路: 真是MDZZ了,模拟. 主要就是开个队列存了一下每个任务结束时间,然后对于每个任务把队列里小于该任务开始时间pop掉,队列里的个数就可以代表当前处理个数了 #include <bits/stdc++.h> using namespace std; typedef long long LL; const int N…
CodeForces - 344A id=46664" style="color:blue; text-decoration:none">Magnets Time Limit: 1000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u Submit Status Description Mad scientist Mike entertains himself by arranging ro…
题意 https://vjudge.net/problem/CodeForces-1236D 最近,爱丽丝得到了一个新玩偶.它甚至可以走路! 爱丽丝为玩偶建造了一个迷宫,并想对其进行测试.迷宫具有n行和m列.有k个障碍物,第i个障碍物位于单元格(xi,yi​)上,这意味着第xi​个行与第yi​列相交的单元格上存在一个禁止通过的障碍物. 然而,玩偶有着缺陷.在同一单元格(包括起始单元格)中,它最多只能笔直走或右转一次.它无法进入有障碍物的单元格或走出迷宫的界限之外. 现在,爱丽丝正在控制娃娃的动作…
大意: n个人, 两个党派, 轮流投票, 两种操作(1)ban掉一个人 (2)投票, 每轮一个未被ban的人可以进行一次操作(1)或操作(2), 求最终哪个党派得票最多. 显然先ban人会更优, 所以维护两个set模拟. 不过好像可以有O(n)的做法? #include <iostream> #include <sstream> #include <algorithm> #include <cstdio> #include <math.h> #i…
题目:这里 题意:n个app,q个操作,当操作数type为1的时候表示y这个app推送了你一条消息,当操作数type为2的时候表示将y这个app已推送的所有消息都读完,当操作数为3的时候 表示将已经推送的前(按推送的时间顺序)y条消息再读一遍(不管这前y条消息中有没有读过的,都再读一遍),问每次操作的时候的未读的消息数是多少? 用队列来模拟就好,记得每次要输出的是所有app的没有读过的消息的总数就行,不要想的太细,把读过的标记一下就行,总是觉得这个会超时,但是一想这才是2的第三题,1 的第一题,…
题意 给出字符串a与b 可以将a中的单个字符改为# 问最少改多少次 a中就找不到b了 一开始想的是用strstr 因为如果找到 可以将strstr(a,b)-a+1改成# 即改首字母 用while循环strstr来做题 然而改第一个字母不行 因为有可能重叠 比如在lll之中找ll 改了第一个还能找出来 但是其实只改一个就可以了 之后又想是不是能改最后一个 但是用strstr不会... 所以最后想出了暴力扫一遍的神奇解法..因为最多 a是五次方 b是30 最多是3乘十的六次方..结果46ms就好了…
大意: 给定序列$a$, 某些位置为'?', 求给'?'赋值使得序列$(a_1+a_2+...+a_k,a_2+a_3+...+a_{k+1},...)严格递增, 且$\sum|a_i|$最小. 化简一下可以得到$a_1<a_{k+1}<a_{2k+1}<...,a_2<a_{k+2}<a_{2k+2}<...$, 所以每一部分都是独立的, 所以单独考虑k个部分, 贪心使得$\sum|a_i|$最小即可. #include <iostream> #inclu…
题目链接 题意: 给定一个字符串,最多更改一个字符,问最多可以有多少个“VK”子串? 思路: 由于数据量很小,不妨尝试暴力写.首先算出不更改任何字符的情况下有多个VK字串,然后尝试每一次更改一个位置的字符,然后暴力算出有多少个VK,取出这些答案中 的最大值,即是答案. 代码: #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <c…
大意: 给定k个字符串, 长度均为n, 求是否存在一个串S, 使得k个字符串都可以由S恰好交换两个字符得到. 暴力枚举交换的两个字符的位置, 计算出交换后与其他串不同字符的个数, 若为1或>2显然不成立, 若为0必须要求存在两个相同的字符. #include <iostream> #include <iostream> #include <algorithm> #include <cstdio> #include <math.h> #inc…