zoj 3620 Escape Time II dfs】的更多相关文章

题目链接: 题目 Escape Time II Time Limit: 20 Sec Memory Limit: 256 MB 问题描述 There is a fire in LTR ' s home again. The fire can destroy all the things in t seconds, so LTR has to escape in t seconds. But there are some jewels in LTR ' s rooms, LTR love jewe…
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=4744 Escape Time II Time Limit: 2 Seconds      Memory Limit: 65536 KB There is a fire in LTR ’ s home again. The fire can destroy all the things in t seconds, so LTR has to escape in t second…
J - Watashi's BG Time Limit:3000MS     Memory Limit:65536KB     64bit IO Format:%lld & %llu Submit Status Practice ZOJ 3631 Appoint description:   Description Watashi is the couch of ZJU-ICPC Team and he is very kind hearted. In ZJU-ICPC summer train…
Strange Country II Time Limit: 1 Second      Memory Limit: 32768 KB      Special Judge You want to visit a strange country. There are n cities in the country. Cities are numbered from 1 to n. The unique way to travel in the country is taking planes.…
题目: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3356 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=26732#problem/D Football Gambling II Time Limit: 3 Seconds      Memory Limit: 65536 KB The 2010 FIFA World Cup toke place betw…
ZOJ - 4124Median 题目大意:有n个元素,给出m对a>b的关系,问哪个元素可能是第(n+1)/2个元素,可能的元素位置相应输出1,反之输出0 省赛都过去两周了,现在才补这题,这题感觉不难,可能那时脑子混了,题意也没理解清楚.根据题目很容易看出,这跟拓扑排序有关,不过拓扑排序的作用在于判断给出的关系是否矛盾,在找判断可能是第(n+1)/2个元素还主要是思维. 哪个元素可能是中间的(n+1)/2个元素呢,就是那些明确在它前面的元素(比它大的)的数目和在它后面的元素(比它小的)的数目都不…
嗯... 题目链接:https://zoj.pintia.cn/problem-sets/91827364500/problems/91827364501 这道题是想出来则是一道很简单的dfs: 将一个4*4的地图给每一个点排序,如下图: 0  1  2  3 4  5  6  7 8  9  10  11 12 13 14 15 设一个点为第k个点,那么它的坐标为(k/n,k%n),根据这个进行dfs,当k == n * n是退出dfs.如果k < n *n,就继续dfs,判断是否能放下,即要…
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=4834 从点1出发,假设现在在i,点数为sta,则下一步的点数必然不能是sta的因数,所以不会形成环,只需从1直接走,走到n即可. 但是如果这样的话时空复杂度就都是nk,明显不满足题意,而这个时候我们可以想到,每个状态都必然是k的约数,(点数不是k的约数的节点不在路上,可以无视),而约数的个数也就k^0.5个,可以直接用map映射,这样时空复杂度都是n*k^0.5,可以解出答案…
题目链接 题意 : 将n*n个正方形进行排列,需要判断相邻的正方形的相邻三角形上边的数字是不是都相等. 思路 : 只知道是个深搜,一开始不知道怎么搜,后来看了题解才明白,就是说不是自己去搜,而是将给定的正方形按照要求一个个往上摆,如果摆不下去了肯定是没有结果的.还有可以将一样的放一起,如果一个在某个位置放不下了,那么其他的更放不下了. #include <stdio.h> #include <iostream> #include <string.h> using nam…
Exchange Cards Time Limit: 2 Seconds      Memory Limit: 65536 KB As a basketball fan, Mike is also fond of collecting basketball player cards. But as a student, he can not always get the money to buy new cards, so sometimes he will exchange with his…
Problem Description   As we know, Rikka is poor at math. Yuta is worrying about this situation, so he gives Rikka some math tasks to practice. There is one of them: Yuta has a non-direct graph with n vertices and n edges. Now he wants you to tell him…
Oil Deposits Time Limit: 2 Seconds      Memory Limit: 65536 KB The GeoSurvComp geologic survey company is responsible for detecting underground oil deposits. GeoSurvComp works with one large rectangular region of land at a time, and creates a grid th…
Ignatius and the Princess II Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 9458    Accepted Submission(s): 5532 Problem Description Now our hero finds the door to the BEelzebub feng5166. He op…
Generalized Palindromic Number Time Limit: 2 Seconds                                     Memory Limit: 65536 KB                             A number that will be the same when it is written forwards or backwards is known as a palindromic number. For…
/* 现将相同的合并计数. 再枚举判断是否符合当cou==n*n是符合就退出 */ #include<stdio.h> #include<string.h> #define N 900 int en[N][4],num[N],real[N][4],len,n,ok; void pp(int a[4],int b[4])//赋值 { a[0]=b[0]; a[1]=b[1]; a[2]=b[2]; a[3]=b[3]; } void print(int a[4]) { printf(…
//我刚开始竟然用bfs做,不断的wa,bfs是用来求最短路的而这道题是求固定时间的 //剪纸奇偶剪枝加dfs #include<stdio.h> #include<queue> #include<math.h> #include<string.h> using namespace std; #define N 10 char ma[N][N]; struct node { int x,y,step; }ss,tt; int dis[4][2]={1,0,-…
题目 给一个嵌套整数序列,请你返回每个数字在序列中的加权和,它们的权重由它们的深度决定. 序列中的每一个元素要么是一个整数,要么是一个序列(这个序列中的每个元素也同样是整数或序列). 与 前一个问题 不同的是,前一题的权重按照从根到叶逐一增加,而本题的权重从叶到根逐一增加. 也就是说,在本题中,叶子的权重为1,而根拥有最大的权重. 示例 1: 输入: [[1,1],2,[1,1]] 输出: 8 解释: 四个 1 在深度为 1 的位置, 一个 2 在深度为 2 的位置. 示例 2: 输入: [1,…
题意: 输入数据n,m.n代表工厂的数量,m代表城市的数量. 接下来n+m行为工厂和城市的坐标. 规定如图所示方向刮风,工厂的air会污染风向地区的air. 注意,工厂和城市的坐标表示的是从x到x+1从y到y+1之间小正方形都是工厂区域,规定如果只有一个coner的air被污染那么该地区视为无污染. 要求输出有多少不被污染的城市. 坑: 思考了很多问题.... 1.加入某城市的正下方是工厂怎么办...这个是否算污染. 2.假如有两个角被污染了怎么办...算污染吗. 坑了一整天.没办法找大神的代码…
本文出自   http://blog.csdn.net/shuangde800 题目链接:zoj-3627 题意 直线上有n个城市, 第i个城市和i+1个城市是相邻的.  每个城市都有vi的金币.    Alice和Bob站在城市p, 他们每天可以选择走向一个相邻的城市, 也可以选择不走. 他们是单独行动的.    他们经过一个城市就可以获得相应的金币(不能重复获得)    作为一个队伍, 他们的最远距离不能操作M, 问T天内, 他们最多一共能拿多少金币? 思路 由于每次只能走一步,那么一定是一…
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=1002 题意:给出一个n,有n*n大小的城市,(.)表示空地,从碉堡(O)射出来的子弹可以前后左右四个方向发射,只有墙壁(X)可以挡住子弹,所以同一行同一列不能出现两座碉堡,除非它们中间有墙壁隔着,问最多能放多少座碉堡. 思路:一个个点遍历,看符不符合条件,符合条件座数+1然后继续下一点. #include<iostream> using namespace std; ]…
There is a hive in the village. Like this. There are 8 columns(from A to H) in this hive. Different colums have the same number of grids. Every grid has its own coordinate, which is formed by two uppercases, representing the row index and the column…
链接:http://www.icpc.moe/onlinejudge/showProblem.do?problemCode=3332 本文链接:http://www.cnblogs.com/Ash-ly/p/5454611.html 题意: 给你一个N,代表含有N个点的竞赛图,接着的N * (N- 1) / 2行两个点u, v,代表存在有向边<u,v>,问是否能构造出来一个哈密顿通路. 思路: 竞赛图一定含有哈密顿通路,不一定含有哈密顿回路.则不可能出现不存在的情况,直接构造就可以,至于方法可…
Given n, generate all structurally unique BST's (binary search trees) that store values 1...n. For example,Given n = 3, your program should return all 5 unique BST's shown below. 1 3 3 2 1 \ / / / \ \ 3 2 1 1 3 2 / / \ \ 2 1 2 3 confused what "{1,#,2…
题意:有n个城市并排着,每个城市有些珠宝,有两个人站在第s个城市准备收集珠宝,两人可以各自行动,但两人之间的距离不能超过dis,而且每经过一个城市就需要消耗1天,他们仅有t天时间收集珠宝,问最多能收集多少珠宝? 思路: 其实就是类似一个滑动窗口在收集一个序列上的权值.首先两个人可以同时往两边散开,直到极限距离dis(这样省时),然后他们可能往左/右走,也可能往左走一会儿再往右走,也可能往右走一会儿再往左走.可以看出其实这些考虑都是对称的,那么我们主要考虑1边就行了.可以尝试枚举往左边走k天,其他…
题意:有一个n*8的蜂房(6边形的格子),其中部分是障碍格子,其他是有蜂蜜的格子,每次必须走1个圈取走其中的蜂蜜,在每个格子只走1次,且所有蜂蜜必须取走,有多少种取法? 思路: 以前涉及的只是n*m的矩阵,也就是四边形的,现在变成了6边形,那么每个格子也就有6个方向可以出/进.为了方便考虑,将蜂房变成按列来扫,那么轮廓线需要2*n+1个插头信息.这里不需要用到括号表示法或者最小表示法,只需要表示该位置是否有线即可,所以每个插头仅需1个位就可以表示了. 转置一下后的蜂房应该是这样的: 轮廓线是一个…
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=3780 题目大意: 给你一个正整数x,要求每个数字上的总和和x相同且比x大的最小整数. 如x=12 答案为21  x=10 答案为100 思路: 因为要比x大的最小,我们很自然的想到个位-1十位+1不就可以了.但是要注意如果是0的话,0-1变为9那么是不行的!而9+1的话变为0也是不行的. 最个位开始查找,找第一个不为0的数-1(不为0的下标为not_zero),在not_ze…
比赛链接: http://acm.hust.edu.cn/vjudge/contest/view.action?cid=44704#overview 题目来源: ZOJ Monthly, June 2012 on June 24 Wine93有话说: 无话可说~~~ 转下wuyiqi巨巨的题解:http://www.cnblogs.com/wuyiqi/archive/2012/06/25/2562806.html     ID Origin Title   6 / 27 Problem A Z…
D. Persistent Bookcase Recently in school Alina has learned what are the persistent data structures: they are data structures that always preserves the previous version of itself and access to it when it is modified. After reaching home Alina decided…
P1006:模拟 然而我的同余方程能过样例然而就是WA⊙﹏⊙b [已查明:扩展欧几里得算法出了很隐蔽的问题] int exGcd(int x,int y,int& a,int& b) //ax+by=gcd(x,y) { ; b=; return x; } int res=exGcd(y,x%y,a,b); int t=a; a=b; b=t-x/y*b; return res; } Correct exGcd Code #include <cstdio> #include &…
Escape Time II Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2966 Description In last winter, there was a big snow storm in South China. The electric system was damaged seriously. Lots of p…