1220. Stacks
又一神题啊 卡内存可以卡到这种地步 省得不行了
开两个【N]数组 一个来记录前驱 一个存数 记录前驱的用unsigned short类型 最大可达65535 不过可以标记一下是否比这个数大 比它大的话就减去 求的时候再加上
#include <iostream>
#include<cstring>
#include<algorithm>
#include<stdlib.h>
#include<cstdio>
using namespace std;
#define N 100010
unsigned short p2[N];
int p1[N];
int stack[];
int main()
{
int n,a,b,g=;
char s[];
scanf("%d",&n);
while(n--)
{
scanf("%s",s);
if(strcmp(s,"PUSH")==)
{
scanf("%d%d%*c",&a,&b);
p1[g] = b;
if(stack[a]>=)
{
p2[g] = stack[a]-;
p1[g] = -p1[g];
}
else
p2[g] = stack[a];
stack[a] = g;
g++;
}
else
{
scanf("%d%*c",&a);
printf("%d\n",abs(p1[stack[a]]));
if(p1[stack[a]]<)
stack[a] = p2[stack[a]]+;
else
stack[a] = p2[stack[a]];
}
}
return ;
}
1220. Stacks的更多相关文章
- [LeetCode] Implement Queue using Stacks 用栈来实现队列
Implement the following operations of a queue using stacks. push(x) -- Push element x to the back of ...
- Leetcode Implement Queue using Stacks
Implement the following operations of a queue using stacks. push(x) -- Push element x to the back of ...
- Device nodes and device stacks
[Device nodes and device stacks] 链接:https://msdn.microsoft.com/en-us/library/windows/hardware/ff5547 ...
- 1220 - Mysterious Bacteria--LightOj1220 (gcd)
http://lightoj.com/volume_showproblem.php?problem=1220 题目大意: 给你一个x,求出满足 x=b^p, p最大是几. 分析:x=p1^a1*p2^ ...
- 2016暑假多校联合---Joint Stacks (STL)
HDU 5818 Problem Description A stack is a data structure in which all insertions and deletions of e ...
- openstack-kilo--issue(九) heat stacks topology中图形无法正常显示
======声明======= 欢迎转载:转载请注明出处 http://www.cnblogs.com/horizonli/p/6186581.html ==========环境=========== ...
- Implement Queue using Stacks
Implement the following operations of a queue using stacks. push(x) -- Push element x to the back of ...
- Bitnami --https://bitnami.com/stacks
Bitnami is an app store for server software. Install your favorite applications in your own servers ...
- poj 1220(短除法)
http://poj.org/problem?id=1220 题意:进制转换,把a进制转换为b进制. 如果数据不大的话,那么这个题还是很简单的,但这个题就是数据范围太大,所以这里可以采用短除法来做. ...
随机推荐
- ActiveMq+zookeeper+levelDB集群整合配置
ActiveMq+zookeeper+levelDB集群整合配置 环境:linux系统,jdk1.7 三台linux系统电脑.我这里使用一台window,分别远程3台linux电脑.三台电脑的ip分 ...
- Django文档——Model字段类型(Field Types)
大部分内容参考自http://wrongwaycn.github.io/django11/topics/db/models/index.html#topics-db-models ,内容是django ...
- WPF中利用后台代码实现窗口分栏动态改变
在WPF中实现窗口分栏并能够通过鼠标改变大小已经非常容易,例如将一个GRID分成竖排三栏显示,就可以将GRID先分成5列,其中两个固定列放GridSplitter. <Grid Backgrou ...
- SQL Server数据库备份(本机)
基础的SQL Server数据库备份存储过程 /**************************************************************************** ...
- EXTJS4.2 控件之Grid getRowClass 添加行背景色
css 样式: /*交流管理系统 开始*/ tr.x-grid-record-blue .x-grid-td { background: #87CEFF; }/*grid 行颜色*/ tr.x-gri ...
- 利用JQuery的$.ajax()可以很方便的调用asp.net的后台方法
利用JQuery的$.ajax()可以很方便的调用asp.net的后台方法. 先来个简单的实例热热身吧. 1.无参数的方法调用 asp.net code: view plaincopy to clip ...
- 有关hadoop分布式配置详解
linux配置ssh无密码登录 配置ssh无密码登录,先要安装openssh,如下: yum install openssh-clients 准备两台linux服务器或虚拟机,设置两台linux的ho ...
- 1047: [HAOI2007]理想的正方形 - BZOJ
Description 有一个a*b的整数组成的矩阵,现请你从中找出一个n*n的正方形区域,使得该区域所有数中的最大值和最小值的差最小.Input 第一行为3个整数,分别表示a,b,n的值第二行至第a ...
- CNKI翻译助手-连接数据库失败
IP并发数限制,老师说西工大的CNKI才20个并发指标,HPU自不必说.但是我略表怀疑,这只是翻译助手而已,就像百度翻译和百度数据库的区别,如何验证呢?去校外用该助手,如果能用,那么就不是IP并发限制 ...
- OD之窗口界面