You are given a function ff written in some basic language. The function accepts an integer value, which is immediately written into some variable xx. xx is an integer variable and can be assigned values from 00 to 232−1232−1. The function contains t…
题目:http://codeforces.com/contest/1175/problem/B B. Catch Overflow! time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You are given a function ff written in some basic language. The function a…
A bracket sequence is a string, containing only characters "(", ")", "[" and "]". A correct bracket sequence is a bracket sequence that can be transformed into a correct arithmetic expression by inserting characters…
吐泡泡题目链接:https://www.nowcoder.com/acm/contest/74/A 题目: 思路: 这种题目当初卡了我很久,今天早训时遇到一个一样得题,一眼就想到用栈模拟,就又回来把这题补了.这题很简单,看代码基本上就能看懂,就不解释了. 代码实现如下: #include <set> #include <map> #include <queue> #include <stack> #include <cmath> #include…
传送门 Description As the new term comes, the Ignatius Train Station is very busy nowadays. A lot of student want to get back to school by train(because the trains in the Ignatius Train Station is the fastest all over the world ^v^). But here comes a pr…
这道题在LA是挂掉了,不过还好,zoj上也有这道题. 题意:好大一颗树,询问父子关系..考虑最坏的情况,30w层,2000w个点,询问100w次,貌似连dfs一遍都会TLE. 安心啦,这肯定是一道正常人能做的题目.不过是需要几个小技巧. 1.2000w个点不一定都要保存下来,事实上,虽然题目给了256M的空间,只要开了两个这么大的数组,MLE是跑不了的,所以只保存30w个父节点. 2.如果这30w个父节点构成一条链,dfs的栈肯定爆.所以需要用栈模拟dfs.这里用的是stack<int>,当然…
Parentheses 题目链接: http://acm.hust.edu.cn/vjudge/contest/127401#problem/A Description http://7xjob4.com1.z0.glb.clouddn.com/9cf04e507e13a41d77bca3a75bb51e19 Input The first line contains an integer T ≤ 10 indicating the number of test cases. The first…
主题链接: id=1363">啊哈哈,点我点我 思路: 这道题就是一道简单的栈模拟. .. .我最開始认为难处理是当出栈后top指针变化了. .当不满足条件时入栈的当前位置怎么办.这时候想到用一个Copy数组保持入栈记录就可以. .当满足全部的火车都出栈时或者已经没有火车能够进栈了,那么久跳出.. 最后推断 是否出栈的火车是否达到n... 题目: Rails Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 24940…
用栈模拟汉诺塔问题 描述 在经典的汉诺塔问题中,有 3 个塔和 N 个可用来堆砌成塔的不同大小的盘子.要求盘子必须按照从小到大的顺序从上往下堆 (如:任意一个盘子,其必须堆在比它大的盘子上面).同时,你必须满足以下限制条件: 每次只能移动一个盘子. 每个盘子从堆的顶部被移动后,只能置放于下一个堆中. 每个盘子只能放在比它大的盘子上面. 请写一段程序,实现将第一个堆的盘子移动到最后一个堆中. 样例 输入 3 输出 towers[0]: [] towers[1]: [] towers[2]: [2,…
1289 大鱼吃小鱼 栈模拟 思路 题目链接 https://www.51nod.com/onlineJudge/questionCode.html#!problemId=1289 思路: 用栈来模拟,O(n)即可 朝右的小鱼进栈,朝左的小鱼来攻关,看能攻几关,栈里的小鱼就GG几条,如果攻不过去,只能自己GG 代码: #include <bits/stdc++.h> using namespace std; int n,dir,size,temp; stack<int> s; in…