武大OJ 622. Symmetrical】的更多相关文章

Description          Cyy likes something symmetrical, and Han Move likes something circular. Han Move gave you a circular string whose length is N, i.e. the i-th character of the string is the neighbor of the ( (i-1) mod N )-th character and ( (i+1)…
Description Give you a number S of length n,you can choose a position and remove the number on it.After that,you will get a new number. More formally,you choose a number x(1<=x<=n),then you will get the number Rx=S1S2…..Sx-1 Sx+1……Sn..The problem is…
Description Today, the math teacher taught Alice Hui Yang’s triangle. However, the teacher came up with a new one, called Sama’s triangle (some of you may be familiar with this name).        In this triangle, there is only 30 row, and the ith row has…
Description Old Sama is a great and powerful magician in the word. One day, a little girl, Anny, touched Sama’s crystal and broke into his magic 2D space. However, Sama is very amiable. So he wanted to send Anny back to the real world instead of trap…
Farmer John has a farm. Betsy, a famous cow, loves running in farmer John's land. The noise she made makes John mad. So he wants to restrict the area Betsy can run. There are nn (4<n\le 20000004<n≤2000000) points of interest (or POI) on the farm, th…
搭建 OJ 需要的知识(重要性排序): Java SE(Basic Knowledge, String, FileWriter, JavaCompiler, URLClassLoader, SecurityManager, synchronized) Java Virutal Machine(Classpath,Policy) Servlet(HttpServlet) JSP(Session, JSP, EL, JSTL, Custom Tags) Tomcat(Classpath) Java…
前言 做过杭电.浙大或是北大等ACM题库的人一定对“刷题”不陌生,以杭电OJ为例:首先打开首页(http://acm.hdu.edu.cn/),然后登陆,接着找到“Online Exercise”下的“Problem Archive”,然后从众多题目中选择一个进行读题.构思.编程.然后提交.最后查看题解状态,如果AC了表示这一题被攻克了,否则就要重做了~一般情况下,“刷题”要求精神高度集中且经验丰富,否则很难成功AC,有时候甚至做一题要浪费半天的时间!(有时网速卡了,比抢火车票还要急!) 楼主在…
import bs4 import requests import urllib2 import time import base64 session=requests.Session() response=session.get('http://oj.blue-whale.me:23331/captcha.php') soup=bs4.BeautifulSoup(response.text) s=soup.find('img') #get the img tag #print s #we ge…
1.一般用C语言节约空间,要用C++库函数或STL时才用C++; cout.cin和printf.scanf最好不要混用. 2.有时候int型不够用,可以用long long或__int64型(两个下划线__). 值类型表示值介于 -2^63 ( -9,223,372,036,854,775,808) 到2^63-1(+9,223,372,036,854,775,807 )之间的整数. printf("%I64d",a); printf("%lld",a); 3.O…
我这校区新的微机老师斗志昂扬,准备让我们这学校萎靡的信息技术竞赛重振雄风.然后有一次我半开玩笑地说建一个自己的OJ吧,老师也就鼓励我去做了. 开什么玩笑……!我可是马上要参加NOIP的人! 于是老师说,慢慢来吧. 嗯,正好我也有兴趣,那就慢慢来吧.先策划一下. 然后我就被吓到了. (注:以下内容纯属纸上谈兵,若坑了请善待><) 零.服务器何在 话说老师办公室里有N台学校淘汰下来的机子,用来做服务器再合适不过了,随便捉一台来装上Linux(学会Linux真是有必要),放在老师办公室24小时挂着,…
Problem Link: https://oj.leetcode.com/problems/validate-binary-search-tree/ We inorder-traverse the tree, and for each node we check if current_node.val > prev_node.val. The code is as follows. # Definition for a binary tree node # class TreeNode: #…
Problem Link: https://oj.leetcode.com/problems/recover-binary-search-tree/ We know that the inorder traversal of a binary search tree should be a sorted array. Therefore, we can compare each node with its previous node in the inorder to find the two…
Problem Link: https://oj.leetcode.com/problems/same-tree/ The following recursive version is accepted but the iterative one is not accepted... # Definition for a binary tree node # class TreeNode: # def __init__(self, x): # self.val = x # self.left =…
Problem Link: https://oj.leetcode.com/problems/symmetric-tree/ To solve the problem, we can traverse the tree level by level. For each level, we construct an array of values of the length 2^depth, and check if this array is symmetric. The tree is sym…
Problem Link: https://oj.leetcode.com/problems/binary-tree-level-order-traversal/ Traverse the tree level by level using BFS method. # Definition for a binary tree node # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # se…
Problem Link: https://oj.leetcode.com/problems/binary-tree-zigzag-level-order-traversal/ Just BFS from the root and for each level insert a list of values into the result. # Definition for a binary tree node # class TreeNode: # def __init__(self, x):…
Problem Link: https://oj.leetcode.com/problems/maximum-depth-of-binary-tree/ Simply BFS from root and count the number of levels. The code is as follows. # Definition for a binary tree node # class TreeNode: # def __init__(self, x): # self.val = x #…
Problem Link: https://oj.leetcode.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal/ The basic idea is same to that for Construct Binary Tree from Inorder and Postorder Traversal. We solve it using a recursive function. First, we…
G++? 首先更正一个概念,C++是一门计算机编程语言,G++不是语言,是一款编译器中编译C++程序的命令而已. 那么他们之间的区别是什么? 在提交题目中的语言选项里,G++和C++都代表编译的方式.准确地说,选择C++的话,意味着你将使用的是最标准的编译方式,也就是ANSI C++编译.如果你使用的是G++的话,意味着你将使用GNU项目中最平凡适用人群最多的编译器(其实也就是我们熟悉的Code::Blocks的自带的编译器,Windows环境里一般是MinGW下的gcc,Linux中的gcc和…
看了园友的评论之后,我也好奇清橙OJ是怎么计算内存占用的.重新测试的情况附在原文后边. -------------------------------------- 这是切割线 -------------------------------------------- 最近自学Java,试着用Java刷几道OJ的题来熟悉基本语法. 起初几道简单题,没太留意程序的执行效率.今天做了一道简单的递归题,竟然运行超时了!由于本人算法方面功底太差,不懂的如何优化,想了个投机的办法应付了过去.但又觉得不可思议…
一. Online Judge简介: Online Judge系统(简称OJ)是一个在线的判题系统.用户可以在线提交程序多种程序(如C.C++.Pascal)源代码,系统对源代码进行编译和执行,并通过预先设计的测试数据来检验程序源代码的正确性. 一个用户提交的程序在Online Judge系统下执行时将受到比较严格的限制,包括运行时间限制,内存使用限制和安全限制等.用户程序执行的结果将被Online Judge系统捕捉并保存,然后再转交给一个裁判程序.该裁判程序或者比较用户程序的输出数据和标准输…
splay缩点. #include<bits/stdc++.h> #define L(t) (t)->c[0] #define R(t) (t)->c[1] #define F(t) (L(t)->s+1) #define G(t) (L(t)->s+(t)->u) #define M (l+r>>1) struct node{ int v,s,u; node* c[2]; node(int v,int s,int u,node* a,node* e)…
本篇用双向链表和模拟栈混洗过程两种解答方式具体解答“栈混洗”的应用问题 有关栈混洗的定义和解释在此篇:手记-栈与队列相关 列车调度(Train) 描述 某列车调度站的铁道联接结构如Figure 1所示. 其中,A为入口,B为出口,S为中转盲端.所有铁道均为单轨单向式:列车行驶的方向只能是从A到S,再从S到B:另外,不允许超车.因为车厢可在S中驻留,所以它们从B端驶出的次序,可能与从A端驶入的次序不同.不过S的容量有限,同时驻留的车厢不得超过m节. 设某列车由编号依次为{1, 2, ..., n}…
Queuing : 提交太多了,OJ无法在第一时间给所有提交以评判结果,后面提交的程序将暂时处于排队状态等待OJ的评判.不过这个过程一般不会很长. Compiling : 您提交的代码正在被编译. Running : 您的程序正在OJ上运行. Judging : OJ正在检查您程序的输出是否正确. Accepted (AC) : 您的程序是正确的,恭喜! Presentation Error (PE) : 虽然您的程序貌似输出了正确的结果,但是这个结果的格式有点问题.请检查程序的输出是否多了或者…
https://leetcode.com/ http://www.cnblogs.com/lzmfywz/archive/2012/02/07/2342010.html 1.题库与网站资源题库-在线提交系统(Online Judge)简介   下面是几个比较大的在线提交系统(OnlineJudge)里面有大量历年的竞赛题目,注册一个ID,然后用自己熟悉的语言(一般有Pascal/C/C++/Java)写好源代码提交即可,会实时返回信息告诉你是否正确.采用黑箱测试,系统里有一套标准的输入输出数据(…
Problem Link: https://oj.leetcode.com/problems/construct-binary-tree-from-inorder-and-postorder-traversal/ This problem can be easily solved using recursive method. By given the inorder and postorder lists of the tree, i.e. inorder[1..n] and postorde…
Problem Link: https://oj.leetcode.com/problems/binary-tree-level-order-traversal-ii/ Use BFS from the tree root to traverse the tree level by level. The python code is as follows. # Definition for a binary tree node # class TreeNode: # def __init__(s…
Problem Link: http://oj.leetcode.com/problems/convert-sorted-array-to-binary-search-tree/ Same idea to Convert Sorted Array to Binary Search Tree, but we use a recursive function to construct the binary search tree. # Definition for a binary tree nod…
Problem Link: http://oj.leetcode.com/problems/convert-sorted-list-to-binary-search-tree/ We design a auxilar function that convert a linked list to a node with following properties: The node is the mid-node of the linked list. The node's left child i…
Problem Link: http://oj.leetcode.com/problems/balanced-binary-tree/ We use a recursive auxilar function to determine whether a sub-tree is balanced, if the tree is balanced, it also return the depth of the sub-tree. A tree T is balanced if the follow…