JSCPC2022 A - PENTA KILL!

2022 Jiangsu Collegiate Programming Contest

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 n ( 1 ≤ n ≤ 10001 ≤ n ≤ 1000 ) n (1\le n \le 10001≤n≤1000) n(1n10001n1000), indicating the number of kills in the game.
Each of the following n n n lines contains two strings a a a and b b b consisting of English letters and digital numbers, indicating that the player named a a a kills the player named b b b. The length of each string won’t exceed 100. It is guaranteed that there are no kills between teammates and there are exactly five players per team.
Ouput
Output PENTA KILL! if a player has achieved PENTA KILL, or SAD:( otherwise.
 
Sample 1
Input

10
Bin Guigo
Grevthar Bin
GALA Grevthar
GALA TitaN
GALA Guigo
GALA Aegis
GALA Jojo
GALA Grevthar
Xiaohu Grevthar
GALA Aegis

Ouput

PENTA KILL!

Sample 2

7
GALA Jojo
GALA Jojo
Aegis GALA
GALA Grevthar
GALA Aegis
GALA Guigo
GALA TitaN

Ouput

PENTA KILL!

Sample 3

7
GALA Jojo
Aegis Ming
GALA Grevthar
GALA Grevthar
GALA Aegis
GALA Guigo
GALA TitaN 

Ouput

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.

解题思路:
在每次记录 a a a 的击杀前就判断 a a a 的击杀记录中是否已经击杀过 b b b 了,若未出现就记录此次击杀,否则上次击杀 b b b 及其前其他击杀记录作废,再记录此次击杀。 (五杀:就是在连续的5次击杀中,都是不一样的敌方英雄)

#include <bits/stdc++.h>
using namespace std;

map<string, vector<string> > kill;

int main()
{
    bool flag = false;
    int n; cin>>n;
    while (n--)
    {
        string a, b;
        cin>>a>>b;
        //查找 a 杀 b 的击杀记录
        auto itpos = find(kill[a].begin(), kill[a].end(), b);
        if(itpos != kill[a].end())
        {
        	//清除之前不连续记录
            kill[a].erase(kill[a].begin(), itpos+1);
        }
        kill[a].push_back(b);
        if(kill[a].size() == 5)
        {
            flag = true;
            break;
        }
    }
    if(flag) cout<<"PENTA KILL!";
    else cout<<"SAD:(";
    return 0;
}
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

花生ono

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值