栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > C/C++/C#

A - PENTA KILL!

C/C++/C# 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

A - PENTA KILL!

SDUT 2022 Spring Individual Contest(for 21) - 10 - Virtual Judge

OLO's global tournament, ISM, is in full swing and Shizuku is a big fan of GNR which is taking part in the tournament. OLO is a game where two teams of five players play against each other. PENTA KILL is considered an unbelievable achievement in the game, which means one player kills five pairwise distinct opponents in a row. We assume that a player will be resurrected immediately after his death, and the death will not affect the verdict of his PENTA KILL.

Normally, PENTA KILL will be displayed in the game. However, sometimes due to unintended disparity in latency between competing teams, it is not displayed properly in the game. After the game, Shizuku gets a chronological list of kills during the game. She wants to know whether a player has achieved PENTA KILL in this game.

Input

The first line contains an integer nn (1le n le 10001≤n≤1000), indicating the number of kills in the game.

Each of the following nn lines contains two strings aa and bb consisting of English letters and digital numbers, indicating that the player named aa kills the player named bb. The length of each string won't exceed 100100. It is guaranteed that there are no kills between teammates and there are exactly five players per team.

Output

Output PENTA KILL! if a player has achieved PENTA KILL, or SAD:( otherwise.

Sample 1

InputcopyOutputcopy
10
Bin Guigo
Grevthar Bin
GALA Grevthar
GALA TitaN
GALA Guigo
GALA Aegis
GALA Jojo
GALA Grevthar
Xiaohu Grevthar
GALA Aegis
PENTA KILL!

Sample 2

InputcopyOutputcopy
7
GALA Jojo
GALA Jojo
Aegis GALA
GALA Grevthar
GALA Aegis
GALA Guigo
GALA TitaN
PENTA KILL!

Sample 3

InputcopyOutputcopy
7
GALA Jojo
Aegis Ming
GALA Grevthar
GALA Grevthar
GALA Aegis
GALA Guigo
GALA TitaN
SAD:(

Note

In the second sample, GALA kills Jojo, Grevthar, Aegis, Guigo, and TitaN in a row so he gets PENTA KILL.

In the third sample, GALA kills Grevthar twice after he kills Jojo so he doesn't kill five distinct opponents in a row.

 

map解法:

#include
using namespace std;
mapm;
mapm2;
string s1[1100];
string s2[1100];
int n,flag;
bool st[1100];
int main()
{
    scanf("%d",&n);
    for(int i=0;i>s1[i];
        cin>>s2[i];
        m[s1[i]]++;
    }
//    for(int i=0;i=5)
        {
            for(int j=i; j1)
                    {
                        m2[s2[j]]--;
                        if(m2.size()<5)
                        {
                            m2.clear();
                            break;
                        }
                        else
                        {
                            break;
                        }
                    }
                }//不知道为啥,}放这就对了
//                cout<=5)
            {
                flag=1;
            }
        }
    }
//    printf("%dn",m2.size());
    if(flag)
       printf("PENTA KILL!n");
    else
        printf("SAD:(n");
}

set解法:

#include
using namespace std;
int main()
{

	int n;
	cin >> n;
	string a[n + 1], b[n + 1];
	map s;
	for (int i = 0; i < n; i ++ )
	{
		cin >> a[i] >> b[i];
 		s[a[i]] ++;
	}
	bool flag = false;
	for (int i = 0; i < n; i ++ )
	{
		if(s[a[i]] < 5)	continue;
		else
		{
			set v;
			for (int j = i; j < n; j ++ )
			{
				if(a[j] == a[i])
				{
					if(v.find(b[j]) == v.end())
						v.insert(b[j]);
					else if(v.find(b[j]) != v.end() && v.size() >= 5)
					{
					    break;
					}
					else if(v.find(b[j]) != v.end() && v.size () < 5)
					{
					    v.clear();
					    break;
					}
				}
			}
			if(v.size() >= 5){
				flag = true;
			}
		}
	}
	if(flag){
		cout << "PENTA KILL!" << endl;
	}else{
		cout << "SAD:(" << endl;
	}

	return 0;
}

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/954553.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号