ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#195436 | #3418. 鹅鸭杀 | dbj | 100 | 84ms | 1540kb | C++11 | 1.8kb | 2023-10-18 19:03:32 | 2023-10-18 22:12:14 |
answer
#include <bits/stdc++.h>
using namespace std;
int n, sum, flag;
string s;
struct node {
string id, place;
};
unordered_map<string, node> m;
unordered_map<string, node>::iterator it;
unordered_map<string, node>::iterator it2;
unordered_map<string, int> us;
struct USER {
string name;
bool live;
} user[1001];
inline int read() {
int f = 1, x = 0;
char ch = getchar();
while (ch < '0' || ch > '9') {
if (ch == '-') {
f = -1;
}
ch = getchar();
}
while (ch >= '0' && ch <= '9') {
x = (x << 3) + (x << 1) + (ch - 48);
ch = getchar();
}
return ~f ? x : -x;
}
signed main() {
n = read();
for (int i = 1; i <= n; i++) {
string fk, nm, idd, pc;
cin >> nm >> fk >> fk >> idd >> fk >> fk >> fk >> pc;
m[nm].id = idd;
m[nm].place = pc;
us[nm] = i;
user[i].name = nm;
}
for (it = m.begin(); it != m.end(); it++) {
pair<string, node> temp1 = *it;
if (temp1.second.id == "duck,") {
// cout << temp1.first << ' ' << "is" << ' ' << "alive" << '\n';
user[us[temp1.first]].live = 1;
continue;
}
for (it2 = m.begin(); it2 != m.end(); it2++) {
if (it2 == it) {
continue;
}
pair<string, node> temp2 = *it2;
if ((temp1.second.id != temp2.second.id) && (temp1.second.place == temp2.second.place)) {
user[us[temp1.first]].live = 0;
// cout << temp1.first << ' ' << "is" << ' ' << "dead" << '\n';
flag = 1;
break;
}
}
if (!flag) {
// cout << temp1.first << ' ' << "is" << ' ' << "alive" << '\n';
user[us[temp1.first]].live = 1;
}
flag = 0;
}
for (int i = 1; i <= n; i++) {
if (user[i].live) {
cout << user[i].name << ' ' << "is" << ' ' << "alive" << '\n';
} else {
cout << user[i].name << ' ' << "is" << ' ' << "dead" << '\n';
}
}
return 0;
}
详细
小提示:点击横条可展开更详细的信息
Test #1:
score: 10
Accepted
time: 0ms
memory: 1248kb
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: 1252kb
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: 1ms
memory: 1252kb
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: 1252kb
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: 0ms
memory: 1252kb
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: 1256kb
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: 1252kb
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: 30ms
memory: 1540kb
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: 32ms
memory: 1540kb
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: 21ms
memory: 1536kb
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