最新文章专题视频专题问答1问答10问答100问答1000问答2000关键字专题1关键字专题50关键字专题500关键字专题1500TAG最新视频文章推荐1 推荐3 推荐5 推荐7 推荐9 推荐11 推荐13 推荐15 推荐17 推荐19 推荐21 推荐23 推荐25 推荐27 推荐29 推荐31 推荐33 推荐35 推荐37视频文章20视频文章30视频文章40视频文章50视频文章60 视频文章70视频文章80视频文章90视频文章100视频文章120视频文章140 视频2关键字专题关键字专题tag2tag3文章专题文章专题2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章专题3
当前位置: 首页 - 科技 - 知识百科 - 正文

CodeforcesRound#283(Div.2)D.TennisGame_html/css

来源:动视网 责编:小采 时间:2020-11-27 16:00:03
文档

CodeforcesRound#283(Div.2)D.TennisGame_html/css

CodeforcesRound#283(Div.2)D.TennisGame_html/css_WEB-ITnose:标程貌似是二分? 我预处理标记了一下,然后从1到n枚举t,因为对于每个t,若s存在,那么s是唯一的,所以枚举t即可。 判断t是否合法,直接暴力的话,会超时 不知道标程大致思想是否跟我的一样,也许就是标程没有标记而是二分来找 但是,我的时间复杂度
推荐度:
导读CodeforcesRound#283(Div.2)D.TennisGame_html/css_WEB-ITnose:标程貌似是二分? 我预处理标记了一下,然后从1到n枚举t,因为对于每个t,若s存在,那么s是唯一的,所以枚举t即可。 判断t是否合法,直接暴力的话,会超时 不知道标程大致思想是否跟我的一样,也许就是标程没有标记而是二分来找 但是,我的时间复杂度


标程貌似是二分?

我预处理标记了一下,然后从1到n枚举t,因为对于每个t,若s存在,那么s是唯一的,所以枚举t即可。

判断t是否合法,直接暴力的话,会超时

不知道标程大致思想是否跟我的一样,也许就是标程没有标记而是二分来找

但是,我的时间复杂度是更优的,n*(1+1/2+1/3+......1/n)=n*lnn的做法


#include#include#include#include#include#include#include#include#include#includeusing namespace std;struct Ans{	int s,t;	Ans(){}	Ans(int a,int b){s=a;t=b;}	bool operator <(Ans x)const	{	return s!=x.s?sbp[t2]))	{	t1=as[bp[t2]]+s;	t2+=s;	y++;	}	else	return 0;	}}int main(){	int i,t,m;	scanf("%d",&n);	for(i=0;i


D. Tennis Game

time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

Petya and Gena love playing table tennis. A single match is played according to the following rules: a match consists of multiple sets, each set consists of multiple serves. Each serve is won by one of the players, this player scores one point. As soon as one of the players scores t points, he wins the set; then the next set starts and scores of both players are being set to 0. As soon as one of the players wins the total ofs sets, he wins the match and the match is over. Heres and t are some positive integer numbers.

To spice it up, Petya and Gena choose new numbers s andt before every match. Besides, for the sake of history they keep a record of each match: that is, for each serve they write down the winner. Serve winners are recorded in the chronological order. In a record the set is over as soon as one of the players scores t points and the match is over as soon as one of the players winss sets.

Petya and Gena have found a record of an old match. Unfortunately, the sequence of serves in the record isn't divided into sets and numberss and t for the given match are also lost. The players now wonder what values ofs and t might be. Can you determine all the possible options?

Input

The first line contains a single integer n ? the length of the sequence of games (1?≤?n?≤?105).

The second line contains n space-separated integersai. Ifai?=?1, then thei-th serve was won by Petya, if ai?=?2, then the i-th serve was won by Gena.

It is not guaranteed that at least one option for numberss and t corresponds to the given record.

Output

In the first line print a single number k ? the number of options for numberss and t.

In each of the following k lines print two integerssi andti ? the option for numberss and t. Print the options in the order of increasingsi, and for equalsi ? in the order of increasingti.

Sample test(s)

Input

51 2 1 2 1

Output

21 33 1

Input

41 1 1 1

Output

31 42 24 1

Input

41 2 1 2

Output

Input

82 1 2 1 1 1 1 1

Output

31 62 36 1

文档

CodeforcesRound#283(Div.2)D.TennisGame_html/css

CodeforcesRound#283(Div.2)D.TennisGame_html/css_WEB-ITnose:标程貌似是二分? 我预处理标记了一下,然后从1到n枚举t,因为对于每个t,若s存在,那么s是唯一的,所以枚举t即可。 判断t是否合法,直接暴力的话,会超时 不知道标程大致思想是否跟我的一样,也许就是标程没有标记而是二分来找 但是,我的时间复杂度
推荐度:
  • 热门焦点

最新推荐

猜你喜欢

热门推荐

专题
Top