首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >专栏 >【CodeForces】696A - Football(连续子串,水)

【CodeForces】696A - Football(连续子串,水)

作者头像
FishWang
发布2025-08-26 20:21:48
发布2025-08-26 20:21:48
8400
代码可运行
举报
运行总次数:0
代码可运行

A. Football

time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

Petya loves football very much. One day, as he was watching a football match, he was writing the players' current positions on a piece of paper. To simplify the situation he depicted it as a string consisting of zeroes and ones. A zero corresponds to players of one team; a one corresponds to players of another team. If there are at least 7 players of some team standing one after another, then the situation is considered dangerous. For example, the situation 00100110111111101 is dangerous and 11110111011101 is not. You are given the current situation. Determine whether it is dangerous or not.

Input

The first input line contains a non-empty string consisting of characters "0" and "1", which represents players. The length of the string does not exceed 100 characters. There's at least one player from each team present on the field.

Output

Print "YES" if the situation is dangerous. Otherwise, print "NO".

Examples

input

代码语言:javascript
代码运行次数:0
运行
复制
001001

output

代码语言:javascript
代码运行次数:0
运行
复制
NO

input

代码语言:javascript
代码运行次数:0
运行
复制
1000000001

output

代码语言:javascript
代码运行次数:0
运行
复制
YES

水题for循环滚过去就行了。

代码如下:

代码语言:javascript
代码运行次数:0
运行
复制
#include <cstdio>
#include <cstring>
int main()
{
	char a[111];
	int l;
	bool flag;
	while (~scanf ("%s",a))
	{
		flag = false;
		l = strlen (a);
		if (l < 7)
		{
			printf ("NO\n");
			continue;
		}
		for (int i = 0 ; i < l-6 ; i++)
		{
			if (flag)		//如果发现成立,立马退出 
				break;
			if (a[i+1] == a[i])
			{
				int num = 1;
				for (int j = i + 1 ; j < l ; j++)
				{
					if (a[j] == a[j-1])
						num++;
					else
						break;
					if (num == 7)
					{
						flag = true;
						break;
					}
				}
			}
		}
		if (flag)
			printf ("YES\n");
		else
			printf ("NO\n");
	}
	return 0;
}
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2016-05-17,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档