QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#404728#6785. What Kind of Friends Are You?LZDYRE 1ms3708kbC++141.8kb2024-05-04 15:51:512024-05-04 15:51:53

Judging History

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

  • [2024-05-04 15:51:53]
  • 评测
  • 测评结果:RE
  • 用时:1ms
  • 内存:3708kb
  • [2024-05-04 15:51:51]
  • 提交

answer

/*
   Created by Fredlin on 24-5-4.
   Which submitted on .
   tag:
*/
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <string>
#include <cstring>
#include <queue>
#include <iomanip>
#include <set>
#include <bitset>
#include <tuple>
#include <unordered_map>

using namespace std;
#define int long long
#define ff first
#define ss second
#define mp(x, y) make_pair(x,y)
#define mtp(x, y, z) make_tuple(x,y,z)
#define rep(x) for(int i=0;i^x;++i)
#define inf 0x3f3f3f3f3f3f3f3f
#define ls k<<1
#define rs k<<1|1
typedef long long ll;
typedef pair <ll, ll> pii;
typedef tuple <ll, ll, ll> tiii;
//inline int find(int x){ return fa[x]=x?x:fa[x]=find(fa[x]]);} 

const int maxn = 250,maxm=30;


int c;
inline int _hash(vector<bool> s){
    int sum=0;
    s.resize(c);
    rep(s.size()) sum=sum*3+s[i];
    return sum;
}

inline void solve() {
    int  n,q,nu;
    string s;
    cin>>n>>q>>c;
    vector<vector<bool>> ss(maxm,vector<bool>(maxn));
    unordered_map<string,int>nm;
    string nmm[maxn];
    //unordered_map<int,string>mp;
    rep(c){
        cin>>nmm[i];
        nm[nmm[i]]=i;
    }
    rep(q){
        cin>>nu;
        for(int j=0;j<nu;j++) {
            cin>>s;
            ss[nm[s]][i] = true;
        }
    }
    unordered_map<int,vector<int>> mp;
    rep(c){
       mp[_hash(ss[i])].push_back(i);
    }
    bool b;
    vector<bool>qry(q);
    rep(n){
        for(int j=0;j<q;j++) cin>>b,qry[j]=b;
        if(mp[_hash(qry)].size()==1) cout<<nmm[mp[_hash(qry)][0]]<<"\n";
        else cout<<"Let's go to the library!!\n";
    }

}

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    signed testCasesCount = 1;
    cin>>testCasesCount;
    while (testCasesCount--) solve();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3708kb

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: -100
Runtime Error

input:

100
98 16
154 rliLiumEVQKkJNnMjAj qnhiLgzjsjRsu eiHrssJvVWBLaRFMQVo TwLVZsRNyEOysXY JtYpguJiCihuObMygLVt YiquXjVeDoe pSkLcJbceYhjx vrVgRvYziqmEpVJdB OYLIFEnoKsDXLtEpyRIF EKTKIOpwEswTWgvihdCa MCCudkhYJC wOkSGOgjZlWgf hTcqiMZqeBCjOmzAt dPWGKzHa iDWjhWBQsoQCInigoNIf qGXWZvcWVJvGUbZ oRLdhU NecdjCwFAikYe...

output:


result: