Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <cstdio>
- using namespace std;
- int main(){
- int n;
- cin >> n;
- vector<vector<int> > v1;
- vector<vector<int> > v2;
- string s;
- char tmpc;
- int j = 0, tmpi;
- v1.resize(n);
- v2.resize(n);
- scanf("%c", &tmpc);
- while(j < n){
- scanf("%c", &tmpc);
- if (tmpc == ' '){
- cout << 'h';
- continue;
- }
- if (tmpc >= '0' && tmpc <= '9'){
- tmpi = (int)tmpc - 48;
- do{
- scanf("%c", &tmpc);
- if (tmpc != ' ' && tmpc != '\n'){
- tmpi = tmpi * 10 + ((int)tmpc - 48);
- // cout << tmpi << endl;
- }
- }while(tmpc != ' ' && tmpc != '\n');
- // cout << "push " << endl;
- v1[j].push_back(tmpi);
- }
- if (tmpc == '\n'){
- j++;
- }
- }
- for (int i = 0; i < n; i++){
- for (int j = 0; j < v1[i].size(); j++)
- v2[v1[i][j] - 1].push_back(i + 1);
- }
- cout << n << endl;
- for (int i = 0; i < n; i++){
- for (int j = 0; j < v2[i].size(); j++)
- cout << v2[i][j] << " ";
- cout << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement