Advertisement
OIQ

content

OIQ
Dec 28th, 2019
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.99 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <string>
  4.  
  5. using namespace std;
  6.  
  7. vector <vector<int>> g;
  8. int index = 1;
  9.  
  10. void getline(int i, string &s) {
  11.     int j = 0;
  12.     while (s[index] != ']') {
  13.         if (isdigit(s[index])) {
  14.             if (s[index] == '1')
  15.                 g[i].push_back(j);
  16.             j++;
  17.         }
  18.        
  19.         index++;
  20.     }
  21. }
  22.  
  23. void getvec(string &s, int n) {
  24.  
  25.     for (int i = 0; i < n; i++) {
  26.         getline(i, s);
  27.         index += 3;
  28.     }
  29. }
  30.  
  31. int getlen(string &s) {
  32.  
  33.     int n = 0;
  34.     int ind = 1;
  35.     while (s[ind] != ']') {
  36.         if (isdigit(s[ind]))
  37.             ++n;
  38.         ind++;
  39.  
  40.     }
  41.  
  42.     return n;
  43.  
  44. }
  45.  
  46. int main() {
  47.  
  48.     string s;
  49.     getline(cin, s);
  50.     s = s.substr(2, s.size() - 3);
  51.     //cout << s << endl;
  52.  
  53.     int m = s[s.size() - 1] - '0';
  54.     //cout << m << endl;
  55.  
  56.     int n = getlen(s);
  57.     //cout << n << endl;
  58.  
  59.     g.resize(n);
  60.  
  61.     s = s.substr(0, s.size() - 3);
  62.     //cout << s << endl;
  63.  
  64.     getvec(s, n);
  65.  
  66.     for (int i = 0; i < n; i++) {
  67.         for (int j = 0; j < g[i].size(); j++)
  68.             cout << g[i][j] << " ";
  69.         cout << endl;
  70.     }
  71.  
  72.     return 0;
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement