汪者连懵(legends.cpp)

良心提示&说明
1.并不需要读懂并实现所有概念就能获得许多分数
2.有下发大样例,大样例与对应数据生成方式相同,题目后有文件比较教程
3.看不懂题面可以参照样例输入理解,请仔细观察样例理解题意
4.[t1,t2]表示t1 时刻到t2 时刻,含t1 和t2.比如[4,6]指4,5,6 时刻
题目背景
某天毒瘤老Q 阿克了膜你赛后闲得慌,找来了小L 开发游戏。
“你开发播报系统,我开发剩下的。”老Q 如是说道,并用1s 瞬间完成了开
发。
然而小L 是个菜鸡,除了瑟瑟发抖什么都不会。请你帮帮萌萌哒小L 吧
题目描述
在毒瘤老Q 的心目中,游戏是这样进行的。


[基本概念]
游戏为蓝红双方对抗,每方5 人.
游戏中会发生一些事件,你需要对某些事件进行播报
数据保证不会有两个事件发生时刻相同
[事件类型]
1.伤害事件
2.击杀野怪事件
3.对话事件
[伤害事件]
输入格式为”t A attack B C”,代表A 对B 在t 时刻造成C 伤害
其中A 和B 是不在同一方的角色
若伤害事件后,B 血量值小于等于0,则称为A 对B 造成了一次击杀
若未造成击杀,你不需要做出任何回应
若A 在[t-10,t-1]时刻间造成过x 连杀,则称此次击杀为x+1 连杀
此时你需要播报内容如下
x=1: ”A Double Kill”
x=2: ”A Triple Kill”
x=3: ”A Quadra Kill”
x>=4:”A Penta Kill”
否则称此次击杀为1 连杀
此时,设A 在上次死亡后共造成y 次击杀(含这次)
此时你需要播报内容如下
y<=2:”A Kill B”
y=3:”A Killing Spree”
y=4:”A Rampage”
y=5:”A Unstoppable”
y=6:”A Godlike”
y>=7:”A Lengendary”
若B 在t 时刻被击杀,则B 会在[t,t+60]时刻处于死亡状态
数据保证角色在死亡状态时不会出现在伤害事件中
B 的血量会在t+61 时刻开始时恢复满
特别的,在0 时刻所有角色血量均为满血量
额外的,在播报以上内容后,你可能还需要播报特殊内容
如果B 在上次死亡后共造成击杀数>=7,则播报”A Shutdown B”
如果此时刻被击杀方所有人处于死亡状态,则播报”ACE”
需要注意的是,特殊播报独立于普通播报,顺序与上文出现顺序相同
具体来说,你可能需要对于一次击杀进行三行播报,例如
AAAA Double Kill
AAAA Shutdown FFFF
ACE
[击杀野怪事件]
输入格式为”t A kill B”,代表A 在t 时刻杀了野怪B,其中B 为一个
字符串
其中A 是一个角色
如果B 不为”Dragon”,则不需要任何播报
否则如果A 是蓝方,播报”Blue team has killed the Dragon”
如果A 是红方,播报”Red team has killed the Dragon”
[对话事件]
输入格式为”t A:S” S 为一个字符串
你不需要做出任何回应
具体的,你可以认为t 之后是一个连续的字符串,可以用一次cin 读入
输入格式
一开始5 行5 个字符串表示蓝方5 人名字
接下来5 行5 个字符串表示红方5 人名字
接下来一行10 个正整数一次表示10 人血量上限
接下来一行一个正整数n 表示一共有n 个事件
接下来n 行表示n 个事件
输出格式
若干行,一行一个播报,按时间排序


样例输入0
lzqwq
lzqaq
lzquq
lzqoq
dlqyl
snzakioi
ysakioi
wyjakioi
jygakioi
zcyakioi
10 1 1 1 1 1 1 1 1 1
13
1 lzqwq:I_am_strong
2 snzakioi attack lzqwq 30
12 snzakioi attack lzqaq 1
22 snzakioi attack lzquq 1
32 snzakioi attack lzqoq 1
38 snzakioi attack dlqyl 123
233 snzakioi attack lzqwq 666
234 snzakioi kill Dragon
2333 snzakioi attack lzqwq 8
8888 snzakioi kill lzqwq
2334 snzakioi attack lzqwq 2
2336 dlqyl attack snzakioi 111
5555 lzqwq:QAQ_I_am_too_weak
样例输出0
snzakioi Kill lzqwq
snzakioi Double Kill
snzakioi Triple Kill
snzakioi Quadra Kill
snzakioi Penta Kill
ACE
snzakioi Godlike
Red team has killed the Dragon
snzakioi Lengendary
dlqyl Kill snzakioi
dlqyl Shutdown snzakioi
样例输入1
1
2
3
4
5
6
7
8
9
10
1 1 1 1 1 1 1 1 1 1
1
51 9 attack 1 5537
样例输出1
9 Kill 1
数据范围
对于数据点1,n=1
对于数据点2,n=2
对于数据点3,n=3
对于数据点1-6,任意两个事件间事件间隔>=80(tip:这意味着不可能出现连
杀)
对于数据点1-9,角色血量均为1(tip:这意味着无需记录血量)
对于数据点1-11,角色名称分别为1,2,3,4,5,6,7,8,9,10(tip:想想这意味
着什么)
对于数据点1-14,只有击杀事件
对于数据点1-17,事件时刻递增
对于所有数据,有n<=2000,
对于所有数据,所有字符串长度不超过50
对于所有数据,字符串只包含大小写字母、数字和下划线
对于所有数据,本题中出现的所有数字均为1 到1000000 之间的正整数

思路:

这道题乍一看,很难得样子,其实却非常简单。

要注意的有以下几点:

1.题目中发生的事件并不按时间排序。

2.在判断连杀的时候,要注意判断的是这次伤害与上次连杀发生的时间。

3.在玩家死亡时,要将记录清空。

贴上代码:

 

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

template < typename T > void read(T &x)
{
    int f = 1;x = 0;char c = getchar();
    for (;!isdigit(c);c = getchar()) if (c == '-') f = -f;
    for (; isdigit(c);c = getchar()) x = x * 10 + c - '0';
    x *= f;
}

struct node
{
    int hp;
    bool team;//0 blue 1 red
    int kill;
    int deadtime;
    int num;
};
map < string, node > player;

struct node2
{
    int t;
    bool q;//0 attack 1 dragon
    string a;
    string b;
    int c;
    bool killed;
}a[2005];

int life[15], n, cnt;

bool cmp(node2 x, node2 y)
{
    return x.t < y.t;
}

int main()
{
    //freopen("legends.in", "r", stdin);
    //freopen("legends.out", "w", stdout);
    for(int i = 1;i <= 5;i++)
    {
        string s;
        cin >> s;
        player[s].num = i;
        player[s].team = 0;
    }
    for(int i = 1;i <= 5;i++)
    {
        string s;
        cin >> s;
        player[s].num = i + 5;
        player[s].team = 1;
    }
    for(int i = 1;i <= 10;i++)
        read(life[i]);
    map < string, node > :: iterator it;
    for(it = player.begin();it != player.end();it++)
        (it->second).hp = life[(it->second).num];
    read(n);
    for(int i = 1;i <= n;i++)
    {
        int tt;
        string st;
        cin >> tt >> st;
        if(st.find(':') == -1)
        {
            string tsb;
            cin >> tsb;
            if(tsb == "attack")
            {
                cnt++;
                a[cnt].killed = 0;
                a[cnt].t = tt;
                int tc;
                string tsc;
                cin >> tsc >> tc;
                a[cnt].q = 0;
                a[cnt].a = st;
                a[cnt].b = tsc;
                a[cnt].c = tc;
            }
            else if(tsb == "kill")
            {
                string tsc;
                cin >> tsc;
                if(tsc == "Dragon")
                {
                    cnt++;
                    a[cnt].killed = 0;
                    a[cnt].a = st;
                    a[cnt].t = tt;
                    a[cnt].q = 1;
                }
            }
        }
    }
    sort(a + 1, a + cnt + 1, cmp);
    for(int i = 1;i <= cnt;i++)
    {
        if(a[i].q == 1)
        {
            if(player[a[i].a].team == 0) cout << "Blue ";
            else cout << "Red ";
            cout << "team has killed the Dragon" << endl;
        }
        else if(a[i].q == 0)
        {
            player[a[i].b].hp -= a[i].c;
            if(player[a[i].b].hp <= 0)
            {
                player[a[i].a].kill++;
                a[i].killed = true;
                int tsum = 1, last = i;
                for(int j = i - 1;j >= 1;j--)
                {
                    if(a[last].t - a[j].t <= 10)
                    {
                        if(a[last].a == a[j].a && a[last].killed && a[j].killed)
                        {
                            last = j;
                            tsum++;
                        }        
                    }
                    else break;
                }
                cout << a[i].a;
                if(tsum == 2) cout << " Double Kill" << endl;
                if(tsum == 3) cout << " Triple Kill" << endl;
                if(tsum == 4) cout << " Quadra Kill" << endl;
                if(tsum >= 5) cout << " Penta Kill" << endl;
                if(tsum == 1)
                {
                    int t = player[a[i].a].kill;
                    if(t <= 2) cout << " Kill " << a[i].b << endl;
                    if(t == 3) cout << " Killing Spree" << endl;
                    if(t == 4) cout << " Rampage" << endl;
                    if(t == 5) cout << " Unstoppable" << endl;
                    if(t == 6) cout << " Godlike" << endl;
                    if(t >= 7) cout << " Lengendary" << endl;
                }
                if(player[a[i].b].kill >= 7)
                    cout << a[i].a << " Shutdown " << a[i].b << endl;
                player[a[i].b].kill = 0;
                player[a[i].b].deadtime = a[i].t;
                player[a[i].b].hp = life[player[a[i].b].num];
                tsum = 1;
                for(int j = i - 1;j >= 1;j--)
                    if(player[a[j].b].team == player[a[i].b].team && a[j].killed && a[i].t - a[j].t <= 60)
                        tsum++;
                if(tsum == 5) cout << "ACE" << endl;
            }
        }
    }
    return 0;
}

 

posted @ 2020-08-24 14:20  Daneel  阅读(215)  评论(0)    收藏  举报