QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#397227#6785. What Kind of Friends Are You?Lezy233AC ✓14ms3732kbC++201.1kb2024-04-23 19:55:342024-04-23 19:55:34

Judging History

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

  • [2024-04-23 19:55:34]
  • 评测
  • 测评结果:AC
  • 用时:14ms
  • 内存:3732kb
  • [2024-04-23 19:55:34]
  • 提交

answer

#include <bits/stdc++.h>
#include <bits/extc++.h>
using std::cin,std::cout,std::vector;
#define endl "\n"
typedef std::pair<int,int> PII;

void solve()
{
    int n,q; cin>>n>>q;
    int c; cin>>c;
    vector<int>aa(c,0);
    vector<std::string>name(c+1);
    __gnu_pbds::gp_hash_table<std::string,int>mp;
    // std::unordered_map<std::string,int>mp;
    for(int i=0;i<c;++i){
        cin>>name[i];
        mp[name[i]]=i;
    }
    name[c]="Let's go to the library!!";
    for(int i=0;i<q;++i){
        int m; cin>>m;
        while(m--){
            std::string s; cin>>s;
            aa[mp[s]]|=1<<i;
        }
    }
    
    std::map<int,int>mp2;
    for(int i=0;i<c;++i){
        if(mp2.contains(aa[i])) mp2[aa[i]]=c;
        else mp2[aa[i]]=i;
    }
    while(n--){
        int tt=0;
        for(int i=0;i<q;++i){
            int t; cin>>t;
            if(t) tt|=1<<i;
        }
        if(mp2.contains(tt)) cout<<name[mp2[tt]]<<endl;
        else cout<<name[c]<<endl;
    }
}

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

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: 14ms
memory: 3732kb

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