QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#321381 | #6785. What Kind of Friends Are You? | iee | AC ✓ | 18ms | 9232kb | C++14 | 873b | 2024-02-04 15:59:58 | 2024-02-04 15:59:59 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
void solve() {
int m, q, n;
cin >> m >> q >> n;
vector<string> name(n);
map<string, int> id;
for (int i = 0; i < n; i++) {
cin >> name[i];
id[name[i]] = i;
}
vector<int> mask(n);
for (int i = 0; i < q; i++) {
int k;
cin >> k;
while (k--) {
string s;
cin >> s;
mask[id[s]] |= (1 << i);
}
}
vector<int> mp(1 << q, -1);
for (int i = 0; i < n; i++) {
int &x = mp[mask[i]];
if (x == -1) x = i;
else if (x != -2) x = -2;
}
while (m--) {
int s = 0;
for (int i = 0, x; i < q; i++) {
cin >> x;
s |= (x << i);
}
if (mp[s] < 0) {
cout << "Let's go to the library!!" << "\n";
} else {
cout << name[mp[s]] << "\n";
}
}
}
int main() {
cin.tie(0)->sync_with_stdio(0);
int t;
cin >> t;
while (t--) {
solve();
}
return 0;
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3528kb
input:
2 3 4 5 Serval Raccoon Fennec Alpaca Moose 4 Serval Raccoon Alpaca Moose 1 Serval 1 Fennec 1 Serval 1 1 0 1 0 0 0 0 1 0 0 0 5 5 11 A B C D E F G H I J K 3 A B K 4 A B D E 5 A B K D E 10 A B K D E F G H I J 4 B D E K 0 0 1 1 1 1 0 1 0 1 1 1 1 1 1 0 0 1 0 1 1 0 1 1 1
output:
Serval Let's go to the library!! Let's go to the library!! Let's go to the library!! Let's go to the library!! B Let's go to the library!! K
result:
ok 8 lines
Test #2:
score: 0
Accepted
time: 18ms
memory: 9232kb
input:
100 98 16 154 rliLiumEVQKkJNnMjAj qnhiLgzjsjRsu eiHrssJvVWBLaRFMQVo TwLVZsRNyEOysXY JtYpguJiCihuObMygLVt YiquXjVeDoe pSkLcJbceYhjx vrVgRvYziqmEpVJdB OYLIFEnoKsDXLtEpyRIF EKTKIOpwEswTWgvihdCa MCCudkhYJC wOkSGOgjZlWgf hTcqiMZqeBCjOmzAt dPWGKzHa iDWjhWBQsoQCInigoNIf qGXWZvcWVJvGUbZ oRLdhU NecdjCwFAikYe...
output:
Let's go to the library!! Let's go to the library!! Let's go to the library!! Let's go to the library!! Let's go to the library!! Let's go to the library!! Let's go to the library!! Let's go to the library!! Let's go to the library!! FJVBxEemjhzUqZxTjU Let's go to the library!! Let's go to the libra...
result:
ok 9542 lines