Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- typedef long long int ll;
- #define read() freopen("input.txt", "r", stdin)
- #define write() freopen("output.txt", "w", stdout)
- void fastIO()
- {
- ios_base::sync_with_stdio(false);
- cin.tie(NULL);
- }
- void solve(string s, string x, string t, int depth)
- {
- if(depth==s.size()){
- cout<<t<<'\n';
- return;
- }
- if(s[depth]=='#'){
- solve(s,x,t+x,depth+1);
- }
- else{
- for(int i=0;i<10;i++){
- char a = i+'0';
- solve(s,x,t+a,depth+1);
- }
- }
- }
- int main()
- {
- //read();
- //write();
- fastIO();
- int n,m;
- while(cin>>n){
- cout<<"--\n";
- vector<string>v;
- for(int i=0;i<n;i++){
- string s;
- cin>>s;
- v.push_back(s);
- }
- cin>>m;
- for(int i=0;i<m;i++){
- string s;
- cin>>s;
- for(int j=0;j<n;j++){
- solve(s,v[j],"",0);
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement