Codeforces Round #200 (Div. 1) BCD】的更多相关文章

为了锻炼个人能力奋力div1 为了不做原题从200开始 B 两个电线缠在一起了 能不能抓住两头一扯就给扯分开 很明显当len为odd的时候无解 当len为偶数的时候 可以任选一段长度为even的相同字符串给它翻过去 即 ++--++++--++ -> ++--------++ -> ++++++++++++ 一直这样下去一定可以翻出结果 但是复杂度很高 不能暴力的去找 考虑用一个栈 依次往里放 每次看到top等于当前的这个字符 意义是当前有一个偶数了  便pop出来 最后判断栈的empty 做…
A. Rational Resistance Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/343/problem/A Description Mad scientist Mike is building a time machine in his spare time. To finish the work, he needs a resistor with a certain resista…
D. Water Tree Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/343/problem/D Description Mad scientist Mike has constructed a rooted tree, which consists of n vertices. Each vertex is a reservoir which can be either empty or…
C. Read Time Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/343/problem/C Description Mad scientist Mike does not use slow hard disks. His modification of a hard drive has not one, but n different heads that can read data i…
B. Alternating Current Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/343/problem/B Description Mad scientist Mike has just finished constructing a new device to search for extraterrestrial intelligence! He was in such a hu…
C. Rational Resistance time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Mad scientist Mike is building a time machine in his spare time. To finish the work, he needs a resistor with a certai…
D. Alternating Current time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Mad scientist Mike has just finished constructing a new device to search for extraterrestrial intelligence! He was in…
思路: dfs序其实是很水的东西.  和树链剖分一样, 都是对树链的hash. 该题做法是:每次对子树全部赋值为1,对一个点赋值为0,查询子树最小值. 该题需要注意的是:当我们对一棵子树全都赋值为1的时候, 我们要查询一下赋值前子树最小值是不是0, 如果是的话, 要让该子树父节点变成0, 否则变0的信息会丢失. 细节参见代码: #include <cstdio> #include <cstring> #include <algorithm> #include <i…
题目链接 这题,关键不是二分,而是如果在t的时间内,将n个头,刷完这m个磁盘. 看了一下题解,完全不知怎么弄.用一个指针从pre,枚举m,讨论一下.只需考虑,每一个磁盘是从右边的头,刷过来的(左边来的之前刷了). 思维是硬伤. #include <iostream> #include <cstdio> #include <cstring> #include <vector> #include <cmath> #include <algori…
Water Tree 给出一棵树,有三种操作: 1 x:把以x为子树的节点全部置为1 2 x:把x以及他的所有祖先全部置为0 3 x:询问节点x的值 分析: 昨晚看完题,马上想到直接树链剖分,在记录时间戳时需要记录一下出去时的时间戳,然后就是很裸很裸的树链剖分了. 稳稳的黄名节奏,因为一点私事所以没做导致延迟了 (ps:后来想了一下,不用树链剖分直接dfs序维护也行...) #include <set> #include <map> #include <list> #i…
D. Water Tree time limit per test 4 seconds memory limit per test 256 megabytes input standard input output standard output Mad scientist Mike has constructed a rooted tree, which consists of n vertices. Each vertex is a reservoir which can be either…
B:The Queue 题目大意:你要去办签证,那里上班时间是[s,t), 你知道那一天有n个人会来办签证,他们分别是在时间点ai来的.每个人办业务要花相同的时间x,问你什么时候来 排队等待的时间最少.  (如果你和某个人同时来排队,你会排在他后面)         所有时间为正整数. 题解: 首先可以模拟出 每个人的业务什么时候会办好,那么最优解要么是在第一个人来之前的一分钟来,即a1-1,要么是在某个人的业务刚办好的时候来. 分别求出要等待的时间即可. 注意如果有多个人同时来,那么只能在这些…
D. Water Tree   Mad scientist Mike has constructed a rooted tree, which consists of n vertices. Each vertex is a reservoir which can be either empty or filled with water. The vertices of the tree are numbered from 1 to n with the root at vertex 1. Fo…
A. Magnets 模拟. B. Simple Molecules 设12.13.23边的条数,列出三个等式,解即可. C. Rational Resistance 题目每次扩展的电阻之一是1Ω的,所以假设当前的电阻为\(\frac{a}{b}\)会变成\(\frac{a+b}{b}\)或\(\frac{a}{a+b}\),其实就是求gcd的过程. D. Alternating Current 若出现连续两个相同的符号,其实线的方向是不变的,最后就是转化成括号匹配. E. Read Time…
简单的树链剖分+线段树 #include<bits\stdc++.h> using namespace std; #define pb push_back #define lson root<<1,l,midd #define rson root<<1|1,midd+1,r ; vector<int>g[M]; ],lazy[M<<],top[M],son[M],fa[M],sz[M],dfn[M],to[M],deep[M],cnt,n; vo…
Read Time 题意:有一个数组,很多指针指在这个数组上,每次每个指针可以向左或向右移动一个位置.给出一些需要访问的位置,问访问用的最少时间. 一个指针只可能转一次方向.二分答案. #include<cstdio> #include<cstring> #include<algorithm> #define MAX(a,b) a>b?a:b using namespace std; ],b[]; int i,n,m; bool can(long long x)…
直达–>Codeforces Round #368 (Div. 2) A Brain’s Photos 给你一个NxM的矩阵,一个字母代表一种颜色,如果有”C”,”M”,”Y”三种中任意一种就输出”#Color”,如果只有”G”,”B”,”W”就输出”#Black&White”. #include <cstdio> #include <cstring> using namespace std; const int maxn = 200; const int INF =…
 cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅.....       其实这个应该是昨天就写完的,不过没时间了,就留到了今天.. 地址:http://codeforces.com/contest/651/problem/A A. Joysticks time limit per test 1 second memory limit per test 256…
A: 题目大意: 在一个multiset中要求支持3种操作: 1.增加一个数 2.删去一个数 3.给出一个01序列,问multiset中有多少这样的数,把它的十进制表示中的奇数改成1,偶数改成0后和给出的01序列相等(比较时如果长度不等各自用0补齐) 题解: 1.我的做法是用Trie数来存储,先将所有数用0补齐成长度为18位,然后就是Trie的操作了. 2.官方题解中更好的做法是,直接将每个数的十进制表示中的奇数改成1,偶数改成0,比如12345,然后把它看成二进制数10101,还原成十进制是2…
Codeforces Round #108 (Div. 2) C. Pocket Book 题意 给定\(N(N \le 100)\)个字符串,每个字符串长为\(M(M \le 100)\). 每次选择\(i, j, k\),然后交换串\(i\)和串\(j\)的长度为\(k\)的前缀. 操作可以做任意次,求最多能得到多少不同的字符串,\(modulo (10^9+7)\). 思路 相当于每个位置的可选字符为该列的不同字符的数量. 代码 C. Pocket Book D. Frames 题意 给定…
Vasiliy's Multiset 题目链接: http://codeforces.com/contest/706/problem/D Description Author has gone out of the stories about Vasiliy, so here is just a formal task description. You are given q queries and a multiset A, initially containing only integer…
Codeforces Round #296 (Div. 1)C. Data Center Drama Time Limit: 2 Sec  Memory Limit: 256 MBSubmit: xxx  Solved: 2xx 题目连接 http://codeforces.com/contest/528/problem/C Description The project of a data center of a Big Software Company consists of n compu…
Codeforces Round #441 (Div. 2) A. Trip For Meal 题目描述:给出\(3\)个点,以及任意两个点之间的距离,求从\(1\)个点出发,再走\(n-1\)个点的最短路径. solution 当\(n=1\)时,答案为\(0\),当\(n=2\)时,答案等于与开始点相连的两条边的最小值,当\(n>2\)时,答案等于与开始点相连的两条边的最小值+三条边最小值*\((n-2)\) 时间复杂度:\(O(1)\) B. Divisiblity of Differen…
Codeforces Round #633(Div.2) \(A.Filling\ Diamonds\) 答案就是构成的六边形数量+1 //#pragma GCC optimize("O3") //#pragma comment(linker, "/STACK:1024000000,1024000000") #include<bits/stdc++.h> using namespace std; function<void(void)> __…
Codeforces Round #734 (Div. 3) 20210920.网址:https://codeforces.com/contest/1551. 编程细节:下标定义不要一会[1,n]一会[0,n)啊- A 用价值为1的硬币a枚+价值为2的硬币b枚,买价值为n的东西,希望ab之差的绝对值尽量小.大水题. B1 给我们一个字符串s,用红色和绿色给s上色,规则如下: 一个字母或者不上色,或者被涂成一种颜色,即不能又红又绿. 被涂成一种颜色的所有字母,必须两两不相同. 红色字母数量=绿色字…
Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate it n = int(raw_input()) s = "" a = ["I hate that ","I love that ", "I hate it","I love it"] for i in ran…
Codeforces Round #354 (Div. 2) Problems     # Name     A Nicholas and Permutation standard input/output 1 s, 256 MB    x3384 B Pyramid of Glasses standard input/output 1 s, 256 MB    x1462 C Vasya and String standard input/output 1 s, 256 MB    x1393…
Codeforces Round #279 (Div. 2) 做得我都变绿了! Problems     # Name     A Team Olympiad standard input/output 1 s, 256 MB  x2377 B Queue standard input/output 2 s, 256 MB  x1250 C Hacking Cypher standard input/output 1 s, 256 MB  x740 D Chocolate standard in…
Codeforces Round #262 (Div. 2) 1003 C. Present time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Little beaver is a beginner programmer, so informatics is his favorite subject. Soon his info…
Codeforces Round #262 (Div. 2) 1004 D. Little Victor and Set time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Little Victor adores the sets theory. Let us remind you that a set is a group of…