fork download
  1. #include <bits/stdc++.h>
  2. #include <ext/pb_ds/assoc_container.hpp>
  3. #include <ext/pb_ds/tree_policy.hpp>
  4.  
  5. using namespace std;
  6. using namespace __gnu_pbds;
  7.  
  8. #define fi first
  9. #define se second
  10. #define mp make_pair
  11. #define pb push_back
  12. #define fbo find_by_order
  13. #define ook order_of_key
  14.  
  15. typedef long long ll;
  16. typedef pair<int,int> ii;
  17. typedef vector<int> vi;
  18. typedef long double ld;
  19. typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
  20. typedef set<int>::iterator sit;
  21. typedef map<int,int>::iterator mit;
  22. typedef vector<int>::iterator vit;
  23.  
  24. int power[6] = {1, 10, 100, 1000, 10000, 100000};
  25. vector<ii> ans;
  26.  
  27. bool check(int x, string a)
  28. {
  29. int pos = int(a.length()) - 1;
  30. while(x)
  31. {
  32. int dig = x%10;
  33. if(a[pos]!='?'&&a[pos]!=char(dig+'0')) return false;
  34. x/=10;
  35. pos--;
  36. }
  37. return true;
  38. }
  39.  
  40. int main()
  41. {
  42. ios_base::sync_with_stdio(0); cin.tie(0);
  43. string a, b;
  44. cin>>a>>b;
  45. int n = a.length();
  46. for(int i = power[n-1]; i + 1 < power[n]; i++)
  47. {
  48. //cerr<<i<<' '<<check(i,a)<<' '<<check(i+1,b)<<'\n';
  49. if(check(i, a)&&check(i+1, b))
  50. {
  51. ans.pb(mp(i, i+1));
  52. }
  53. }
  54. cout<<ans.size()<<'\n';
  55. for(int i = 0; i < ans.size(); i++)
  56. {
  57. cout << ans[i].fi << ' ' << ans[i].se << '\n';
  58. }
  59. }
  60.  
Success #stdin #stdout 0s 3468KB
stdin
Standard input is empty
stdout
0