题意:模拟栈,正常pop,push,多一个merge A B 形象地说就是就是将栈B堆到栈A上。

题解:直接用list 的pop_back,push_back,splice 模拟,

坑:用splice,第一次超时,正要大改 发现是cin超时。。。

#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<vector>
#include<cstring>
#include<set>
#include<algorithm>
#include<stack>
#include<string>
#include<cstdio>
#include<list>
#define _for(i, a, b) for (int i = (a); i<(b); ++i)
using namespace std;
const int N = 3e5 + ;
const int INF = 1e6;
list<int> v[N]; int main()
{
int t;
cin >> t;
while (t--) {
int n, q; int a, b; cin >> n >> q;
_for(i, , n + )v[i].clear();
while (q--) {
int x;
scanf("%d", &x);
if (x == ) {
scanf("%d%d", &a, &b);
v[a].push_back(b);
}
if (x == ) {
int b; scanf("%d", &b);
if (v[b].empty())printf("EMPTY\n");
else {
printf("%d\n", v[b].back());
v[b].pop_back();
} }
if (x == ) {
scanf("%d%d", &a, &b);
v[a].splice(v[a].end(), v[b]);
}
}
}
//system("pause");
return ;
}

Mergeable Stack 直接list内置函数。(152 - The 18th Zhejiang University Programming Contest Sponsored by TuSimple)的更多相关文章

  1. The 18th Zhejiang University Programming Contest Sponsored by TuSimple -C Mergeable Stack

    题目链接 题意: 题意简单,就是一个简单的数据结构,对栈的模拟操作,可用链表实现,也可以用C++的模板类来实现,但是要注意不能用cin cout,卡时间!!! 代码: #include <std ...

  2. ZOJ 4016 Mergeable Stack(from The 18th Zhejiang University Programming Contest Sponsored by TuSimple)

    模拟题,用链表来进行模拟 # include <stdio.h> # include <stdlib.h> typedef struct node { int num; str ...

  3. 152 - - G Traffic Light 搜索(The 18th Zhejiang University Programming Contest Sponsored by TuSimple )

    http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5738 题意 给你一个map 每个格子里有一个红绿灯,用0,1表示 ...

  4. 性能测试总结工作总结-基于WebService协议脚本 内置函数手动编写

    LoadRunner基于WebService协议脚本 WebService协议脚本有三种生成方式,一种是直接通过LoadRunner导入URL自动解析生成:一种是使用LoadRunner内置函数手动编 ...

  5. [Hive - Tutorial] Built In Operators and Functions 内置操作符与内置函数

    Built-in Operators Relational Operators The following operators compare the passed operands and gene ...

  6. Day3 - Python基础3 函数、递归、内置函数

    Python之路,Day3 - Python基础3   本节内容 1. 函数基本语法及特性 2. 参数与局部变量 3. 返回值 嵌套函数 4.递归 5.匿名函数 6.函数式编程介绍 7.高阶函数 8. ...

  7. Orace内置函数大全[转:http://www.cnblogs.com/lfx0692/articles/2395950.html]

    NewProgramer   Oracle SQL 内置函数大全(转) SQL中的单记录函数 1.ASCII 返回与指定的字符对应的十进制数;SQL> select ascii('A') A,a ...

  8. python全栈开发-Day12 三元表达式、函数递归、匿名函数、内置函数

    一. 三元表达式 一 .三元表达式 仅应用于: 1.条件成立返回,一个值 2.条件不成立返回 ,一个值 def max2(x,y): #普通函数定义 if x > y: return x els ...

  9. Python入门之三元表达式\列表推导式\生成器表达式\递归匿名函数\内置函数

    本章目录: 一.三元表达式.列表推导式.生成器表达式 二.递归调用和二分法 三.匿名函数 四.内置函数 ================================================ ...

随机推荐

  1. Tomcat------启动出错

    描述:在cmd中,执行startup.bar时,报错:Using CLASSPATH: "E:\Tomcat\bin\bootstrap.jar;E:\Tomcat\bin\tomcat-j ...

  2. C#------Aspose.cells使用方法

    转载: http://www.cnblogs.com/muer/p/yaxle.html 代码: public ActionResult ImportData(HttpPostedFileBase f ...

  3. ios开发之--仿(微信)自定义表情键盘

    先附上demo:https://github.com/hgl753951/CusEmoji.git 效果图如下:

  4. weblogic上部署项目出错

    一. Unable to access the selected application. Exception in AppMerge flows' progression Exception in ...

  5. 【代码审计】711cms_V1.0.5 目录遍历漏洞分析

      0x00 环境准备 711CMS官网: https://www.711cms.com/ 网站源码版本:711CMS 1.0.5 正式版(发布时间:2018-01-20) 程序源码下载:https: ...

  6. 导入贴图操作:处理贴图MaxSize和Format

    using UnityEngine; using System.Collections; using UnityEditor; public class ImportModflyTextures : ...

  7. centos6.4安装GCC

    1. Last login: Mon Aug  4 11:46:15 2014 from 10.3.7.128 [jifeng@jifeng04 ~]$ ls hadoop  jdk1.7.0_45  ...

  8. 《转》windows下通过cmd切换python2和python3版本

    当电脑中同时安装了python2和python3时,往往会由切换版本的需求.那么如何通过cmd命令行做到呢? 方法:修改python.exe的文件名 举个栗子: 我的电脑中同时安装了py2.7.10和 ...

  9. linux系统环境搭建

    一.安装jdk 参考帖子 用yum安装JDK(CentOS) 1.查看yum库中都有哪些jdk版本 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 [r ...

  10. Androidの矢量图形之VectorDrawable研究

    5.0以上支持VectorDrawable了,可以创建vector的xml资源文件.vector其实就使用来绘制矢量图形的. 看一个例子: <?xml version="1.0&quo ...