Basic Data Structure Time Limit: 7000/3500 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Problem Description Mr. Frog learned a basic data structure recently, which is called stack.There are some basic operations of stack: ∙ PUSH x: p…
Basic Data Structure Time Limit: 7000/3500 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 872    Accepted Submission(s): 236 Problem Description Mr. Frog learned a basic data structure recently, which is called stac…
题意:给定一种二进制操作nand,为 0 nand 0 = 10 nand 1 = 1 1 nand 0 = 1 1 nand 1 = 0 现在要你模拟一个队列,实现PUSH x 往队头塞入x,POP队尾退出,REVERSE翻转,QUERY询问队头到队尾的nand和. 思路:其他都可以模拟,但是n为2e5,如果直接求nand和必超时,找规律可得,任何串和0nand都为1,那么我们维护一个双端队列保存0出现的位置,然后每次就计算离队尾最近的0和队尾间有几个1. 代码: #include<set>…
ゲート 分析: 这题看出来的地方就是这个是左结合的,不适用结合律,交换律. 所以想每次维护答案就不怎么可能了.比赛的时候一开始看成了异或,重读一遍题目了以后就一直去想了怎么维护答案...... 但是很容易看出来是置, 是取反.于是维护一下最左边以及最右边的的位置就可以了.要注意一下特殊情况,只有一个是,只有一个是. 剩下的就是用一个数组模拟栈,细节情况有点多,需要考虑很仔细才能通过. 代码: /***************************************************…
Mr. Frog learned a basic data structure recently, which is called stack.There are some basic operations of stack: ∙∙ PUSH x: put x on the top of the stack, x must be 0 or 1. ∙∙ POP: throw the element which is on the top of the stack. Since it is too…
题目链接: Basic Data Structure Time Limit: 7000/3500 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 207    Accepted Submission(s): 41 Problem Description Mr. Frog learned a basic data structure recently, which is called…
Basic Data Structure Time Limit: 7000/3500 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 982    Accepted Submission(s): 253 Problem Description Mr. Frog learned a basic data structure recently, which is called stac…
题意:给你一张无向图,要求对这张图进行删边操作,要求删边之后的图的总边数 >= ceil((n + m) / 2), 每个点的度数 >= ceil(deg[i] / 2).(deg[i]是原图中i的度数) 思路1:模拟 + 乱搞 直接暴力删就行了,读入边之后随机打乱一下就很难被hack了. 代码: #include <bits/stdc++.h> #define LL long long #define INF 0x3f3f3f3f #define db double #defin…
Hanoi Tower Troubles Again! Problem Description People stopped moving discs from peg to peg after they know the number of steps needed to complete the entire task. But on the other hand, they didn't not stopped thinking about similar puzzles with the…
题意: 维护一个栈,支持以下操作: 从当前栈顶加入一个0或者1: 从当前栈顶弹掉一个数: 将栈顶指针和栈底指针交换: 询问a[top] nand a[top-1] nand ... nand a[bottom]的值. nand是这样定义的: ∙∙ 0 nand 0 = 1 ∙∙ 0 nand 1 = 1 ∙∙ 1 nand 0 = 1 ∙∙ 1 nand 1 = 0 关键是要发现性质,任何数nand 0,都会变成1.反复nand上1的话,则值会交替变化. 所以假设当前栈顶在左侧,只需要找到最右侧…