UOJ Logo

NOI.AC

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#195167#3418. 鹅鸭杀liyumo10014ms1656kbC++1.8kb2023-10-18 18:31:492023-10-18 21:55:39

answer

#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <cstdio>
#define in int
#define maxn 10005
using namespace std;
in n,m;
in read()
{
    in xy = 0, ff = 1;
    char ch = getchar();
    while(ch < '0' || ch > '9')
    {
        if(ch == '-')
        {
            ff = -1;
        }
        ch = getchar();
    }
    while(ch >= '0' && ch <= '9')
    {
        xy = xy*10+ch-'0';
        ch = getchar();
    }
    return xy*ff;
} 
inline void write(in res)
{
    if(res<0)
    {
        putchar('-');
        res=-res;
    }
    if(res>9)
        write(res/10);
    putchar(res%10+'0');
}
#include <string>
#include <map>
map <string,bool> mp;
char s[1000000];
string name[maxn],id[maxn],place[maxn];
string now;
int main()
{
    in n=read();

    for(in i=1;i<=n;i++)
    {
        gets(s);
        in tot=1;
        for(in j=0;j<strlen(s);j++)
        {
            if(s[j]==' '||s[j]==',')
            {
                if(tot==1)
                {
                    name[i]=now;
                }
                else if(tot==4)
                {
                    id[i]=now;
                }
                now="";
                tot++;
            }
            else
            {
                now+=s[j];
            }
        }
        place[i]=now;
        now="";
        // cout<<name[i]<<" "<<id[i]<<" "<<place[i]<<endl;
        if(id[i]=="duck")
        {
            mp[place[i]]=true;
        }
    }
    for(in i=1;i<=n;i++)
    {
        if(id[i]=="duck")
        {
            cout<<name[i]<<" is alive\n";
        }
        else if(mp[place[i]])
        {
            cout<<name[i]<<" is dead\n";
        }
        else
        {
            cout<<name[i]<<" is alive\n";
        }
    }
    // system("pause");
    return 0;
}

Details

小提示:点击横条可展开更详细的信息

Test #1:

score: 10
Accepted
time: 0ms
memory: 1448kb

input:

1
DnONuKkfsK is a duck, it is at VxdjvTXugQrxHcBy

output:

DnONuKkfsK is alive

result:

ok single line: 'DnONuKkfsK is alive'

Test #2:

score: 10
Accepted
time: 0ms
memory: 1452kb

input:

1
h is a goose, it is at DgPHXhVJtkESkHmf

output:

h is alive

result:

ok single line: 'h is alive'

Test #3:

score: 10
Accepted
time: 0ms
memory: 1452kb

input:

2
HRiAYWN is a goose, it is at EL
dgwgYboiuaytmJOAv is a duck, it is at EL

output:

HRiAYWN is dead
dgwgYboiuaytmJOAv is alive

result:

ok 2 lines

Test #4:

score: 10
Accepted
time: 0ms
memory: 1448kb

input:

2
izNydjl is a goose, it is at qYWlAosa
EISnxurnHqHNKDD is a goose, it is at qYWlAosa

output:

izNydjl is alive
EISnxurnHqHNKDD is alive

result:

ok 2 lines

Test #5:

score: 10
Accepted
time: 2ms
memory: 1448kb

input:

10
NSWzSOl is a duck, it is at VCLAQReUMFYoH
owVUjFuAPuutSaKhLqh is a duck, it is at ZYPmZsegdxJOuB
...

output:

NSWzSOl is alive
owVUjFuAPuutSaKhLqh is alive
iamfqstvZbCYSDhlDnbq is alive
T is alive
zGub is alive...

result:

ok 10 lines

Test #6:

score: 10
Accepted
time: 0ms
memory: 1448kb

input:

10
kjbxCSWpMH is a duck, it is at FIlDOBA
gxRn is a duck, it is at zXofss
vIFtyFL is a duck, it is a...

output:

kjbxCSWpMH is alive
gxRn is alive
vIFtyFL is alive
PFeZj is alive
uEy is alive
qnoZYPzR is alive
Rff...

result:

ok 10 lines

Test #7:

score: 10
Accepted
time: 0ms
memory: 1448kb

input:

10
CdhUNaBieDYujJ is a goose, it is at ftZTshCjDGgjvPZ
e is a duck, it is at HHvP
fnjTJMUYgydjEeAFet...

output:

CdhUNaBieDYujJ is alive
e is alive
fnjTJMUYgydjEeAFet is alive
Vvc is alive
MLHmWVs is alive
AYDTmkf...

result:

ok 10 lines

Test #8:

score: 10
Accepted
time: 4ms
memory: 1652kb

input:

1000
zS is a duck, it is at uZoViqfzXzBHnojfjo
WUzyrypHYFMkE is a goose, it is at RqXtorsLNPVXWX
mbV...

output:

zS is alive
WUzyrypHYFMkE is dead
mbVP is alive
iWelC is alive
DqMTir is alive
Zr is alive
BsHCmmN i...

result:

ok 1000 lines

Test #9:

score: 10
Accepted
time: 5ms
memory: 1648kb

input:

1000
luK is a duck, it is at Jr
kz is a duck, it is at Q
momuTR is a duck, it is at beRModCS
HmqEgsw...

output:

luK is alive
kz is alive
momuTR is alive
HmqEgswLg is dead
uFNEeUULkDT is alive
uQgDGhomNgYQuwndOxKn...

result:

ok 1000 lines

Test #10:

score: 10
Accepted
time: 3ms
memory: 1656kb

input:

1000
IbBJmdORPKZQEUANbGl is a duck, it is at OJplxaPZjvPj
BzokAqyWjUIVWu is a duck, it is at xxYRvKG...

output:

IbBJmdORPKZQEUANbGl is alive
BzokAqyWjUIVWu is alive
tLHbuTjOxzopobuOMg is alive
rLeadcccgsTAuIbpOGU...

result:

ok 1000 lines

Extra Test:

score: 0
Extra Test Passed