Advertisement
Guest User

Untitled

a guest
Jan 18th, 2020
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.91 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #define all(x) x.begin(), x.end()
  3. #define fast_pls ios_base::sync_with_stdio(false); cin.tie(NULL);
  4. using namespace std;
  5. using ll = unsigned long long;
  6. const ll INF = 1e9 + 100;
  7. const int N = 1e5;
  8.  
  9.  
  10. int main() {
  11. /// freopen("in.txt", "r", stdin);
  12. int n;
  13. scanf("%d", &n);
  14. vector<vector<int>> a(n);
  15. vector<string> ans(n);
  16. for (int i = 0; i < n; i++) {
  17. string s;
  18. scanf(" ");
  19. getline(cin, s);
  20. for (int j = 0; j < s.size(); j++) {
  21. if (isdigit(s[j]))
  22. a[i].push_back(s[j] - '0');
  23. }
  24. }
  25. int m;
  26. scanf("%d", &m);
  27. for (int i = 0; i < m; i++) {
  28. string CC, OC, PC, C;
  29. cin >> CC >> OC >> PC;
  30. CC.erase(CC.begin());
  31. OC.erase(OC.begin());
  32. OC.pop_back();
  33. string shablon = CC + OC + PC;
  34. cin >> C;
  35. scanf(" ");
  36. getline(cin, C);
  37. for (int j = 0; j < n; j++) {
  38. if (shablon.size() != a[j].size()) continue;
  39. bool f = true;
  40. for (int l = 0; l < shablon.size(); l++) {
  41. if (isdigit(shablon[l])) {
  42. if (shablon[l] - '0' != a[j][l])
  43. f = false;
  44. }
  45. }
  46. if (f) {
  47. string res;
  48. res.push_back('+');
  49. for (int l = 0; l < CC.size(); l++) res.push_back(a[j][l] + '0');
  50. res.append(" (");
  51. for (int l = 0; l < OC.size(); l++) res.push_back(a[j][l + CC.size()] + '0');
  52. res.append(") ");
  53. for (int l = 0; l < PC.size(); l++) res.push_back('0' + a[j][l + CC.size() + OC.size()]);
  54. res.append(" - ");
  55. res.append(C);
  56. ans[j] = std::move(res);
  57. }
  58. }
  59. }
  60. for (int i = 0; i < n; i++) cout << ans[i] << "\n";
  61. return 0;
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement