Advertisement
999ms

Untitled

Nov 7th, 2021
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. #define all(x) begin(x),end(x)
  4.  
  5. using namespace std;
  6. using ll = long long;
  7. using ld = long double;
  8.  
  9. vector<int> parseString(string s) {
  10. vector<int> res;
  11. int pre = 0;
  12. for (int i = 0; i < int(s.size()); i++) {
  13. if (s[i] == ' ') {
  14. res.push_back(stoi(s.substr(pre, i - pre)));
  15. pre = i + 1;
  16. }
  17. }
  18. if (!s.empty()) {
  19. res.push_back(stoi(s.substr(pre, int(s.size()) - pre)));
  20. }
  21. return res;
  22. }
  23.  
  24. void solve() {
  25. string s;
  26. getline(cin, s);
  27. int n, m;
  28. {
  29. auto v = parseString(s);
  30. n = v[0];
  31. m = v[1];
  32. }
  33. vector<int> c(m);
  34. for (int i = 0; i < m; i++) {
  35. getline(cin, s);
  36. auto v = parseString(s);
  37. c[i] = v[0];
  38. }
  39.  
  40. vector<vector<int>> arr(n), brr(m);
  41. for (int i = 0; i < n; i++) {
  42. getline(cin, s);
  43. arr[i] = parseString(s);
  44. }
  45.  
  46. for (int i = 0; i < m; i++) {
  47. getline(cin, s);
  48. brr[i] = parseString(s);
  49. }
  50.  
  51.  
  52. cout << n << ' ' << m << '\n';
  53.  
  54. for (auto val: c) cout << val << ' ';
  55. cout << '\n';
  56. for (auto v: arr) {
  57. for (auto val: v) cout << val << ' ';
  58. cout << '\n';
  59. }
  60. cout << '\n';
  61. for (auto v: brr) {
  62. for (auto val: v) cout << val << ' ';
  63. cout << '\n';
  64. }
  65.  
  66.  
  67. }
  68.  
  69. int main() {
  70. ios_base::sync_with_stdio(false);
  71. cin.tie(nullptr);
  72. cout.tie(nullptr);
  73. int t = 1;
  74. while (t--) {
  75. solve();
  76. }
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement