Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <string>
- using namespace std;
- vector <vector<int>> g;
- int index = 1;
- void getline(int i, string &s) {
- int j = 0;
- while (s[index] != ']') {
- if (isdigit(s[index])) {
- if (s[index] == '1')
- g[i].push_back(j);
- j++;
- }
- index++;
- }
- }
- void getvec(string &s, int n) {
- for (int i = 0; i < n; i++) {
- getline(i, s);
- index += 3;
- }
- }
- int getlen(string &s) {
- int n = 0;
- int ind = 1;
- while (s[ind] != ']') {
- if (isdigit(s[ind]))
- ++n;
- ind++;
- }
- return n;
- }
- int main() {
- string s;
- getline(cin, s);
- s = s.substr(2, s.size() - 3);
- //cout << s << endl;
- int m = s[s.size() - 1] - '0';
- //cout << m << endl;
- int n = getlen(s);
- //cout << n << endl;
- g.resize(n);
- s = s.substr(0, s.size() - 3);
- //cout << s << endl;
- getvec(s, n);
- for (int i = 0; i < n; i++) {
- for (int j = 0; j < g[i].size(); j++)
- cout << g[i][j] << " ";
- cout << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement