QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#184107#6785. What Kind of Friends Are You?ucup-team004#AC ✓17ms3820kbC++201.2kb2023-09-20 12:52:242023-09-20 12:52:26

Judging History

你现在查看的是最新测评结果

  • [2023-09-20 12:52:26]
  • 评测
  • 测评结果:AC
  • 用时:17ms
  • 内存:3820kb
  • [2023-09-20 12:52:24]
  • 提交

answer

#include <bits/stdc++.h>

using i64 = long long;

void solve() {
    int n, q;
    std::cin >> n >> q;
    
    int c;
    std::cin >> c;
    
    std::vector<std::string> p(c);
    std::map<std::string, int> id;
    for (int i = 0; i < c; i++) {
        std::cin >> p[i];
        id[p[i]] = i;
    }
    
    std::vector<int> ans(c);
    for (int i = 0; i < q; i++) {
        int m;
        std::cin >> m;
        
        for (int j = 0; j < m; j++) {
            std::string s;
            std::cin >> s;
            ans[id[s]] |= 1 << i;
        }
    }
    
    std::map<int, int> cnt, f;
    for (int i = 0; i < c; i++) {
        cnt[ans[i]]++;
        f[ans[i]] = i;
    }
    for (int i = 0; i < n; i++) {
        int mask = 0;
        for (int j = 0; j < q; j++) {
            int x;
            std::cin >> x;
            mask |= x << j;
        }
        if (cnt[mask] == 1) {
            std::cout << p[f[mask]] << "\n";
        } else {
            std::cout << "Let's go to the library!!\n";
        }
    }
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    
    int t;
    std::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: 0ms
memory: 3820kb

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: 17ms
memory: 3664kb

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