135 - ZOJ Monthly, August 2014】的更多相关文章

135 - ZOJ Monthly, August 2014 A:构造问题,推断序列奇偶性.非常easy发现最小值不是1就是0.最大值不是n就是n - 1,注意细节去构造就可以 E:dp.dp[i][j]表示长度i,末尾状态为j的最大值,然后每一个位置数字取与不取,不断状态转移就可以 G:就一个模拟题没什么好说的 H:dfs,每次dfs下去,把子树宽度保存下来,然后找最大值,假设有多个.就是最大值+cnt宽度 I:构造,假设r * 2 > R,肯定无法构造.剩下的就二分底边.按等腰三角形去构造就…
Abs Problem Time Limit: 2 Seconds Memory Limit: 65536 KB Special Judge Alice and Bob is playing a game, and this time the game is all about the absolute value! Alice has N different positive integers, and each number is not greater than N. Bob has a…
A Abs Problem http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5330 找规律题,构造出解.copyright@ts #include<cstdio> int main() { int n,big,sma,id; while(~scanf("%d",&n)) { ) { puts("1 1"); puts("); puts("); contin…
做了一次月赛,没想到这么难,加上后来补上的题目也只有3个题.第一名也只有4个题啊啊啊啊~.其中两道还是水题.留坑慢慢补上来. 3832 Tilt Cylinder 给定如图所示有盖圆柱体,R,H,水面高度h,倾角a,求水得体积. 分析:明显的数值积分题,这样考虑.圆下底面即A点与地面高度lim1, 圆上底面一点B与地面高度lim2,h所处的范围进行讨论从而确定积分几何体的两边的高度.我们积分的几何体应该是一个圆柱体被削掉一部分了. h>lim1时,几何体左半部分可以减掉一个圆柱,对剩下部分积分,…
比赛链接:点击打开链接 上来先搞了f.c,,然后发现状态不正确,一下午都是脑洞大开,, 无脑wa,无脑ce...一样的错犯2次.. 硬着头皮搞了几发,最后20分钟码了一下G,不知道为什么把1直接当成不能加油的站就会wa..太弱.. 唔···太懒第二天才发题解.. B:Gears 并查集 题解:点击打开链接 C:Consecutive Blocks 离散化一下然后模拟 题解:点击打开链接 D:An Easy Game 设dp[i][j]为前i个位置已经匹配了j个位置的方法数. #include <…
链接 虽做出的很少,也记录下来,留着以后来补..浙大题目质量还是很高的 B 并查集的一些操作,同类和不同类我是根据到根节点距离的奇偶判断的,删点是直接新加一个点,记得福大月赛也做过类似的,并差集的这类关系题目还是比较常见的,有空深究一下. #include <iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<stdlib.h> #include<…
Poker Face Time Limit: 2 Seconds      Memory Limit: 65536 KB As is known to all, coders are lack of exercise and Kato is one of them. In order to get fit, he decides to go mining in MINECRAFT. However, it is always dangerous in the mine because there…
A.Another Recurrence Sequence problemId=5287">B.Gears 题目大意:有n个齿轮,一開始各自为一组.之后进行m次操作,包含下面4种类型: 1.合并两组齿轮.合并的两个应该反向旋转 2.把某个齿轮从所在组删除,自为一组.但不影响同组其他齿轮的状态与关系 3.询问两个齿轮是同向.反向或无关系(即不在同一组) 4.询问某个齿轮所在组的齿轮总数 分析:典型的并查集操作,可是注意两点: 1.因为操作3要询问两个齿轮的相对状态.因此对并查集中每一个元素应…
题目链接  ZOJ Monthly, March 2018 Problem G 题意  给定一个字符串.现在求一个下标范围$[0, n - 1]$的$01$序列$f$.$f[x] = 1$表示存在一种方案,删掉原字符串中的连续$x$个字母, 使得剩下的字符串中任意相邻的两个字母都不同.在这道题中所有的字符串首尾字符看做是相邻的. 对于每个起始位置求出最多往右延伸到的位置,满足该区间代表的字符串是一个满足任意相邻字母不同的字符串. 首先考虑一个连续的满足任意相邻字母不同的字符串.设其长度为$l$…
题目链接  ZOJ Monthly, March 2018 Problem F 题意很明确 这个模数很奇妙,在$[0, mod)$的所有数满足任意一个数立方$48$次对$mod$取模之后会回到本身. 所以开$48$棵线段树,和一个永久标记.当对某个区间操作时对这个区间加一层永久标记. 即当前我要查找的第$x$层,实际找的是第$up[i] + x$层. 时间复杂度$O(48nlogn)$ #include <bits/stdc++.h> using namespace std; #define…
题目传送门 /* 题意:n个时刻点,m次时光穿梭,告诉的起点和终点,q次询问,每次询问t时刻t之前有多少时刻点是可以通过两种不同的路径到达 思维:对于当前p时间,从现在到未来穿越到过去的是有效的值,排个序,从大到小询问,那么之前添加的穿越点都是有效的, 用multiset保存.比赛时想到了排序,但是无法用线段树实现查询,stl大法好! */ #include <cstdio> #include <algorithm> #include <cstring> #includ…
ZOJ 3406 Another Very Easy Task #include <cstdio> #include <cstring> const int N = 100005; char s[N]; int main() { bool f = 0; int size = 0; char ch; while(scanf("%c", &ch)!=EOF) { if( !(ch >= 'a' && ch <='z') &…
[题目链接] A. ZOJ 4004 - Easy Number Game 首先肯定是选择值最小的 $2*m$ 进行操作,这些数在操作的时候每次取一个最大的和最小的相乘是最优的. #include <bits/stdc++.h> using namespace std; const int maxn = 100010; int T, n, m; long long a[maxn]; int main() { scanf("%d", &T); while(T--) {…
A - Easy Number Game 水. #include <bits/stdc++.h> using namespace std; #define ll long long #define N 100010 ll arr[N]; int n, m; int main() { int t; scanf("%d", &t); while (t--) { scanf("%d%d", &n, &m); ; i <= n; +…
A是水题,此处略去题解 B - PreSuffix ZOJ - 3995 (fail树+LCA) 给定多个字符串,每次询问查询两个字符串的一个后缀,该后缀必须是所有字符串中某个字符串的前缀,问该后缀最长时,是多少个字符串的前缀. 思路:对所有串构造ac自动机,根据fail指针的性质,a节点的fail指针指向b时,b一定是a的某个后缀.所以每次询问对两个字符串对应的节点在fail树上求一下LCA,插入时经过了LCA节点的字符串的个数便是答案. #include<bits/stdc++.h> us…
A.ZOJ 3666 Alice and Bob 组合博弈,SG函数应用 #include<vector> #include<cstdio> #include<cstring> #include<algorithm> using namespace std; const int maxn = 10000 + 100; int SG[maxn]; vector<int> g[maxn]; int mex(int u) { //minimal exc…
Bob wants to pour water Time Limit: 2 Seconds      Memory Limit: 65536 KB      Special Judge There is a huge cubiod house with infinite height. And there are some spheres and some cuboids in the house. They do not intersect with others and the house.…
Prime Query Time Limit: 1 Second      Memory Limit: 196608 KB You are given a simple task. Given a sequence A[i] with N numbers. You have to perform Q operations on the given sequence. Here are the operations: A v l, add the value v to element with i…
Market Time Limit: 2 Seconds      Memory Limit: 65536 KB There's a fruit market in Byteland. The salesmen there only sell apples. There are n salesmen in the fruit market and the i-th salesman will sell at most wi apples. Every salesman has an immedi…
Number Game Time Limit: 2 Seconds      Memory Limit: 65536 KB The bored Bob is playing a number game. In the beginning, there are n numbers. For each turn, Bob will take out two numbers from the remaining numbers, and get the product of them. There i…
Cake Time Limit: 4 Seconds      Memory Limit: 65536 KB Alice and Bob like eating cake very much. One day, Alice and Bob went to a bakery and bought many cakes. Now we know that they have bought n cakes in the bakery. Both of them like delicious cakes…
Ant Time Limit: 1 Second      Memory Limit: 32768 KB There is an ant named Alice. Alice likes going hiking very much. Today, she wants to climb a cuboid. The length of cuboid's longest edge is n, and the other edges are all positive integers. Alice's…
B http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5552 输入n,表示有n个数1到n.A先拿,B后拿,依次拿,每次可以拿任意一个数,同时会删去这个数的所有因子,最后谁没得拿了谁输. 解法:推了前几个,0,a输,别的a都能赢,证明没想,猜过去的. 网上一个人说的,也不是很清晰:“如果先取的在2-n中取必输,则先取1, 否则则在2-n中取,同时会把1取走,必赢” #include<cstdio> int main(){ in…
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3844 第一个,n个数,每次操作最大数和最小数都变成他们的差值,最后n个数相同时输出此时的值,暴力跑. #include<cstdio> int main(){ ]; while(~scanf("%d",&t)){ while(t--){ scanf("%d",&n); ;i<n;i++){ scanf(&qu…
A题 题目大意:给出一棵树,一开始节点值均为0,先要求完成在线操作:将某子树所有节点值取反,或者查询某子树总点权. 题解:很基础的线段树题,既然两个操作都是子树操作,那么就先树链剖分一下,将子树操作转变成线段树上的区间操作,区间翻转操作就等同于区间长度减去区间总权值,码量适中,水过. #include <cstdio> #include <algorithm> #include <climits> #include <cstring> using names…
A 易知最优的方法是一次只拿一颗,石头数谁多谁赢,一样多后手赢 #include <map> #include <set> #include <ctime> #include <cmath> #include <queue> #include <stack> #include <vector> #include <string> #include <cstdio> #include <cstd…
A. Easy Number Game 贪心将第$i$小的和第$2m-i+1$小的配对即可. #include<cstdio> #include<algorithm> using namespace std; const int N=100010; int n,m,i,Case,a[N];long long ans; int main(){ scanf("%d",&Case); while(Case--){ scanf("%d%d",…
Description Before ACM can do anything, a budget must be prepared and the necessary financial support obtained. The main income for this action comes from Irreversibly Bound Money (IBM). The idea behind is simple. Whenever some ACM member has any sma…
A - Candy Game 水. #include <bits/stdc++.h> using namespace std; #define N 1010 int t, n; int a[N], b[N]; int main() { scanf("%d", &t); while (t--) { scanf("%d", &n); ; i <= n; ++i) scanf("%d", a + i); ; i <…
A - Peer Review Water. #include <bits/stdc++.h> using namespace std; int t, n; int main() { scanf("%d", &t); while (t--) { scanf("%d", &n); ; i <= n; ++i) printf("0%c", " \n"[i == n]); } ; } B - Bor…