CodeForces - 1255C(构造+模拟)】的更多相关文章

题意 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的肯定是序列的头或尾,因为序列可以反转(得到同样的三元…
题意: 给你一个串只有小写字母和点,让你构造前缀是1-8,后缀是1-3长度的文件名: 思路: 那么以"."作为分割点,把字符串都拿出来,然后 首段长度<=8 OK; 中间<=11 OK; 尾段<=3 OK; 否则都不行: 啊,水题啊,wa了一次,T了一次,神TM都是数据开小了, 一个是4e5写成5e4... 一个是不满足的情况可能会很长,才开了...25... #include <bits/stdc++.h> using namespace std; ty…
题意 https://vjudge.net/problem/CodeForces-1255D rxc的农场里'R'表示有米,现在有K只鸡,给这k只鸡选一些格子,每个鸡可以有多个格子(每个鸡至少吃一个米),但是每个鸡的格子必须连通.问吃到最多的米和最少的米的差最小是多少. 思路 如果农场一共有cnt个米,那么最优的分配肯定是差值为1或0,即给每个鸡先分cnt/k个米,然后把多余的分配给每个鸡.因为鸡的格子必须是连通的,所以可以考虑类似蛇形填数的方法,每找到cnt/k(多余的类似)个米就换下一只鸡,…
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…
题意:给你一个01串,问其是否能拆成若干形如0101010的子串,若能,输出所有子串的0,1 的位置. 题解:一开是暴力,然后瞎找规律, 最后找到一种神奇的线性构造法:扫一遍字符串,若为0就一直竖着往下写0,碰到1就回头往上写,再碰到0 就回头往下写······判断无法构造的依据:如果写1写得超过了上界就跳出,如果最后写的0不在最下面也跳出//codeforces上看到的一段代码秀的脑壳疼 坑:之前随便找规律,写了个巨丑的代码,逻辑混乱,直接wa掉. 无脑写的直接T了 ac #define _C…
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…
B - Save the problem! CodeForces - 867B 这个题目还是很简单的,很明显是一个构造题,但是早训的时候脑子有点糊涂,想到了用1 2 来构造, 但是去算这个数的时候算错了... 用1 2 来构造 可以先枚举一些数来找找规律. 1 1 2 2 3 1 1 1    2 1 1 4 .... 可以发现每一个数都是 n/2+1 的可能, 所以反过来推过去就是 (s-1)*2  或者(s-1)*2+1 这个(s-1)*2+1的答案才是正确答案 因为 这个s可以==1 #i…
题目链接: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…
大意: 无向图, 无重边自环, 每个点度数>=3, 要求完成下面任意一个任务 找一条结点数不少于n/k的简单路径 找k个简单环, 每个环结点数小于n/k, 且不为3的倍数, 且每个环有一个特殊点$x$, $x$只属于这一个环 任选一棵生成树, 若高度>=n/k, 直接完成任务1, 否则对于叶子数一定不少于k, 而叶子反向边数>=2, 一定可以构造出一个环 #include <iostream> #include <algorithm> #include <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…
                                                                                                  G. New Roads                                                                                                time limit per test 2 seconds               …
坑点 不记它难解我心头之恨-- WA1:不要读错题Orz,顺序是按它给定的.那就是个类似栈的东西,重点在于输出. 然而我输出很快就模拟对了-- WA2:数据:1 int.我日了不看数据我真的去de模拟的bug了. WA3:中间栈空是非法. 貌似建一棵树可以迅速搞掉--擦 #include <cstdio> #include <cstring> #include <iostream> #include <string> #include <vector&…
http://codeforces.com/contest/725/problem/C Each English letter occurs at least once in s. 注意到题目有这样一句话,那么就是说S中只有一个重复的字母.一定要看到这句话,不然做不了. 然后就找到pos1和pos2分别代表那两个字母的位置,把他们中间的所有字母对折一下,放在最右边就可以了.因为这样才能用上同一个位置. 只有连续两个相同的字母才会impossible,同样是因为只有两个相同的字母. #includ…
题意: 给一个字符串代表相邻学生的比较,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​列相交的单元格上存在一个禁止通过的障碍物. 然而,玩偶有着缺陷.在同一单元格(包括起始单元格)中,它最多只能笔直走或右转一次.它无法进入有障碍物的单元格或走出迷宫的界限之外. 现在,爱丽丝正在控制娃娃的动作…