We were afraid of making this problem statement too boring, so we decided to keep it short. A sequenceis called non-boring if its every connected subsequence contains a unique element, i.e. an element suchthat no other element of that subsequence has the same value.
Given a sequence of integers, decide whether it is non-boring.
Input
The first line of the input contains the number of test cases T . The descriptions of the test cases follow:Each test case starts with an integer n (1 ≤ n ≤ 200000) denoting the length of the sequence. Inthe next line the n elements of the sequence follow, separated with single spaces. The elements are
non-negative integers less than 109.
Output
Print the answers to the test cases in the order in which they appear in the input. For each test caseprint a single line containing the word ‘non-boring’ or ‘boring’.
Sample Input
4
5
1 2 3 4 5
5
1 1 1 1 1
5
1 2 3 2 1
5
1 1 2 1 1
Sample Output
non-boring
boring
non-boring
boring
此题暴露了复杂度分析的缺点。
//
// main.cpp
// uva 1608 - Non-boring sequences
//
// Created by XD on 15/8/15.
// Copyright (c) 2015年 XD. All rights reserved.
//
/*
此题是分治法的应用,将一个大问题可以分解为一个两个小问题,然后逐个解决。
另外在分析递归程序的复杂度时候尽量将式子写出来,然后分析一下。另外在查找某个值的时候从两边同时查找的期望小一些,这也是分治法好处。
另外要额外注意预处理,预处理是挖掘一下数据的性质,并按照算法的需求来加以存储,使得在算法执行过程中可以简化复杂度。
内联函数。。是指在编译的时候直接将函数的调用替换成函数体的形式,而不是调用,这样可以一定程度的提高执行效率。
同时注意内联函数是需要函数体和声明连在一起的。
*/
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include