[ZOJ 4024] Peak】的更多相关文章

题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=4024 从前往后找满足al<al+1的最大下标l,从后往前找满足ar−1>ar的最小下标r,如果l=r且1<l<n则满足条件 #include <iostream> #include <cstdio> using namespace std; const int maxn = 100005; int arr[maxn]; in…
ZOJ 4024 Peak 题意 给出n和n个数,判断该数列是否是凸形的. 解题思路 从前往后第一对逆序数,和从后往前第一队逆序数,如果都非零而且相邻,证明该数组是凸形的. 代码 #include <cstdio> + ; int a[maxn]; int main() { int T; scanf("%d", &T); while(T--) { int n; scanf("%d", &n); ; i < n; i++) { sca…
剑指Offer 面试题45:圆圈中最后剩下的数字(约瑟夫环问题) 原书题目:0, 1, - , n-1 这n个数字排成一个圈圈,从数字0开始每次从圆圏里删除第m个数字.求出这个圈圈里剩下的最后一个数字. 牛客网改编:孩子们的游戏(圆圈中最后剩下的数) 提交网址: http://www.nowcoder.com/practice/f78a359491e64a50bce2d89cff857eb6?tpId=13&tqId=11199 参与人数:1699  时间限制:1秒 空间限制:32768K 本题…
第十三届浙江省大学生程序设计竞赛 I 题, 一道模拟题. ZOJ  3944http://www.icpc.moe/onlinejudge/showProblem.do?problemCode=3944 In a BG (dinner gathering) for ZJU ICPC team, the coaches wanted to count the number of people present at the BG. They did that by having the waitre…
A peak element is an element that is greater than its neighbors. Given an input array where num[i] ≠ num[i+1], find a peak element and return its index. The array may contain multiple peaks, in that case return the index to any one of the peaks is fi…
A Simple Tree Problem Time Limit: 3 Seconds      Memory Limit: 65536 KB Given a rooted tree, each node has a boolean (0 or 1) labeled on it. Initially, all the labels are 0. We define this kind of operation: given a subtree, negate all its labels. An…
Problem: A peak element is an element that is greater than its neighbors. Given an input array where num[i] ≠ num[i+1], find a peak element and return its index. The array may contain multiple peaks, in that case return the index to any one of the pe…
A peak element is an element that is greater than its neighbors. Given an input array where num[i] ≠ num[i+1], find a peak element and return its index. The array may contain multiple peaks, in that case return the index to any one of the peaks is fi…
There is an integer array which has the following features: The numbers in adjacent positions are different. A[0] < A[1] && A[A.length - 2] > A[A.length - 1]. We define a position P is a peek if: A[P] > A[P-1] && A[P] > A[P+1]…
这道题目还是简单的,但是自己WA了好几次,总结下: 1.对输入的总结,加上上次ZOJ Problem Set - 1334 Basically Speaking ac代码及总结这道题目的总结 题目要求输入的格式: START X Y Z END 这算做一个data set,这样反复,直到遇到ENDINPUT.我们可以先吸纳一个字符串判断其是否为ENDINPUT,若不是进入,获得XYZ后,吸纳END,再进行输出结果 2.注意题目是一个圆周,所以始终用锐角进行计算,即z=360-z; 3.知识点的误…