The 18th Zhejiang University Programming Contest Sponsored by TuSimple -C Mergeable Stack
题目链接
题意:
题意简单,就是一个简单的数据结构,对栈的模拟操作,可用链表实现,也可以用C++的模板类来实现,但是要注意不能用cin cout,卡时间!!!
代码:
#include <stdio.h> #include <iostream> #include <vector> #include <deque> #include <list> #define IO ios::sync_with_stdio(0);\ cin.tie();cout.tie(); using namespace std; *+; list <int > q[N]; int main() { int T; scanf("%d",&T); //cin >> T; while(T--) { int n,q1; scanf("%d%d",&n,&q1); ; i <= n; i++) q[i].clear(); while(q1--) { int op,s,v,t; scanf("%d",&op); ) { scanf("%d%d",&s,&v); q[s].push_back(v); } ) { scanf("%d",&s); if(q[s].empty()) { //cout << "EMPTY" << endl; printf("%s\n", "EMPTY"); } else { //cout << q[s].back() <<endl; printf("%d\n",q[s].back()); q[s].pop_back(); } } ) { scanf("%d%d",&s,&t); q[s].splice(q[s].end(),q[t]); //将s,t合并,并清除t中元素 //q[t].clear(); } } } ; }
The 18th Zhejiang University Programming Contest Sponsored by TuSimple -C Mergeable Stack的更多相关文章
- zoj 4020 The 18th Zhejiang University Programming Contest Sponsored by TuSimple - G Traffic Light(广搜)
题目链接:The 18th Zhejiang University Programming Contest Sponsored by TuSimple - G Traffic Light 题解: 题意 ...
- Mergeable Stack 直接list内置函数。(152 - The 18th Zhejiang University Programming Contest Sponsored by TuSimple)
题意:模拟栈,正常pop,push,多一个merge A B 形象地说就是就是将栈B堆到栈A上. 题解:直接用list 的pop_back,push_back,splice 模拟, 坑:用splice ...
- 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表示 ...
- The 18th Zhejiang University Programming Contest Sponsored by TuSimple
Pretty Matrix Time Limit: 1 Second Memory Limit: 65536 KB DreamGrid's birthday is coming. As hi ...
- 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 ...
- ZOJ 4019 Schrödinger's Knapsack (from The 18th Zhejiang University Programming Contest Sponsored by TuSimple)
题意: 第一类物品的价值为k1,第二类物品价值为k2,背包的体积是 c ,第一类物品有n 个,每个体积为S11,S12,S13,S14.....S1n ; 第二类物品有 m 个,每个体积为 S21,S ...
- The 19th Zhejiang University Programming Contest Sponsored by TuSimple (Mirror) B"Even Number Theory"(找规律???)
传送门 题意: 给出了三个新定义: E-prime : ∀ num ∈ E,不存在两个偶数a,b,使得 num=a*b;(简言之,num的一对因子不能全为偶数) E-prime factorizati ...
- The 19th Zhejiang University Programming Contest Sponsored by TuSimple (Mirror)
http://acm.zju.edu.cn/onlinejudge/showContestProblems.do?contestId=391 A Thanks, TuSimple! Time ...
- The 17th Zhejiang University Programming Contest Sponsored by TuSimple J
Knuth-Morris-Pratt Algorithm Time Limit: 1 Second Memory Limit: 65536 KB In computer science, t ...
随机推荐
- 无线局域网中RADIUS协议原理与实现
转载自:http://blog.csdn.net/jinhill/article/details/5901042 摘要 RADIUS协议是一个被广泛应用于网络认证.授权和计费的协议.本文在介绍了RA ...
- vue实现菜单权限控制
大家在做后台管理系统时一般都会涉及到菜单的权限控制问题.当然解决问题的方法无非两种——前端控制和后端控制.我们公司这边的产品迭代速度较快,所以我们是从前端控制路由迭代到后端控制路由.下面我会分别介绍这 ...
- 使用 log4j 在控制台 打印 hibernate 语句参数
log4j.rootLogger=INFO, stdoutlog4j.appender.stdout=org.apache.log4j.ConsoleAppenderlog4j.appender.st ...
- 【BZOJ】1703: [Usaco2007 Mar]Ranking the Cows 奶牛排名
[题意]给定n头牛和m对大小关系,求最坏情况下至少还需要比较几对奶牛的大小(在未确定顺序的奶牛对中随机比较) [算法]floyd求传递闭包 [题解]可达说明大小已知,则不可达点对数量就是最少比较次数. ...
- ie6下双边距的问题
1.ie6双边距情况 <div class="red"></div> <div class="blue"></div& ...
- 64_k2
kf5-libkdepim-akonadi-17.04.1-1.fc26.x86_64.rpm 25-May-2017 12:22 177198 kf5-libkdepim-devel-17.04.1 ...
- 64_j2
jetty-websocket-server-9.4.3-3.v20170317.fc26.n..> 14-Apr-2017 12:03 62034 jetty-websocket-servle ...
- gcc -rpath 指定动态库路径
gcc -rpath 指定动态库路径 http://blog.csdn.net/v6543210/article/details/44809405
- python 使用headless chrome滚动截图
from selenium import webdriver from selenium.webdriver.chrome.options import Options import util chr ...
- 【uva10779】收集者的难题
按照题意建模就行了. #include<bits/stdc++.h> #define naive 0 #define inf 1000000007 using namespace std; ...