-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathBerOs_File_Suggestion.cpp
More file actions
47 lines (47 loc) · 1.03 KB
/
BerOs_File_Suggestion.cpp
File metadata and controls
47 lines (47 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false)
#define ff first
#define ss second
#define fo(i,n) for(int i=0;i<n;i++)
#define pb push_back
#define lli long long int
#define setbits(x) __builtin_popcountll(x)
#define inf 1e18
#define sfp(x,y) fixed<<setprecision(x)<<y
#define mod 1000000007
int main()
{
fast;
int n;cin>>n;
string s;
map<string,string> mp1;
map<string,int>mp2;
set<string> p;
fo(i,n)
{
cin>>s;p.clear();
fo(i,s.size())
{
for(int j=1;i+j<=s.size();j++)
{
p.insert(s.substr(i,j));
}
}
for(auto it=p.begin();it!=p.end();it++)
{
if(!mp2.count(*it))
{
mp2[*it]=1;mp1[*it]=s;
}
else mp2[*it]++;
}
}
int q; cin>>q;
while (q--){
cin>>s;
if (mp2.count(s)) cout<<mp2[s]<<' '<<mp1[s]<<endl;
else cout<<"0 -"<<endl;
}
return 0;
}