题目链接: 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…
题意: 维护一个栈,支持以下操作: 从当前栈顶加入一个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的话,则值会交替变化. 所以假设当前栈顶在左侧,只需要找到最右侧…
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…
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…
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…
ゲート 分析: 这题看出来的地方就是这个是左结合的,不适用结合律,交换律. 所以想每次维护答案就不怎么可能了.比赛的时候一开始看成了异或,重读一遍题目了以后就一直去想了怎么维护答案...... 但是很容易看出来是置, 是取反.于是维护一下最左边以及最右边的的位置就可以了.要注意一下特殊情况,只有一个是,只有一个是. 剩下的就是用一个数组模拟栈,细节情况有点多,需要考虑很仔细才能通过. 代码: /***************************************************…
题意:给定一种二进制操作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>…
题:https://codeforces.com/contest/1236/problem/E 粗自:https://www.cnblogs.com/YSFAC/p/11715522.html #include<bits/stdc++.h> using namespace std; #define lson root<<1,l,midd #define rson root<<1|1,midd+1,r typedef long long ll; ; ll a[M],tre…
描述 给一个空数列,有M次操作,每次操作是以下三种之一: (1)在数列后加一个数 (2)求数列中某位置的值 (3)撤销掉最后进行的若干次操作(1和3) 输入 第一行一个正整数M. 接下来M行,每行开头是一个字符,若该字符为'A',则表示一个加数操作,接下来一个整数x,表示在数列后加一个整数x:若该字符为'Q',则表示一个询问操作,接下来一个整数x,表示求x位置的值:若该字符为'U',则表示一个撤销操作,接下来一个整数x,表示撤销掉最后进行的若干次操作. 输出 对每一个询问操作单独输出一行,表示答…