Advertisement
erfanul007

UVa 628

Jun 8th, 2019
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. typedef long long int ll;
  5.  
  6. #define read() freopen("input.txt", "r", stdin)
  7. #define write() freopen("output.txt", "w", stdout)
  8.  
  9. void fastIO()
  10. {
  11. ios_base::sync_with_stdio(false);
  12. cin.tie(NULL);
  13. }
  14.  
  15. void solve(string s, string x, string t, int depth)
  16. {
  17. if(depth==s.size()){
  18. cout<<t<<'\n';
  19. return;
  20. }
  21. if(s[depth]=='#'){
  22. solve(s,x,t+x,depth+1);
  23. }
  24. else{
  25. for(int i=0;i<10;i++){
  26. char a = i+'0';
  27. solve(s,x,t+a,depth+1);
  28. }
  29. }
  30. }
  31.  
  32. int main()
  33. {
  34. //read();
  35. //write();
  36. fastIO();
  37. int n,m;
  38. while(cin>>n){
  39. cout<<"--\n";
  40. vector<string>v;
  41. for(int i=0;i<n;i++){
  42. string s;
  43. cin>>s;
  44. v.push_back(s);
  45. }
  46. cin>>m;
  47. for(int i=0;i<m;i++){
  48. string s;
  49. cin>>s;
  50. for(int j=0;j<n;j++){
  51. solve(s,v[j],"",0);
  52. }
  53. }
  54. }
  55. return 0;
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement