fork download
  1. #include <bits/stdc++.h>
  2. #define ll long long
  3. #define endl "\n"
  4.  
  5. using namespace std;
  6.  
  7. int main(){
  8. ios::sync_with_stdio(0);
  9. cin.tie(0);
  10. cout.tie(0);
  11. int t, n;
  12. cin >> t >> n;
  13. vector <vector <int>> a(n + 1, vector <int> (n + 1));
  14. vector <vector <int>> b(n + 1);
  15. vector <int> cnt_deg_sub(n + 1, 0);
  16. for (int i = 1; i <= n; ++i){
  17. for (int j = 1; j <= n; ++j){
  18. cin >> a[i][j];
  19. if (a[i][j] == 1){
  20. b[i].push_back(j);
  21. ++cnt_deg_sub[j];
  22. }
  23. }
  24. }
  25. if (t == 1){
  26. for (int i = 1; i <= n; ++i){
  27. cout << cnt_deg_sub[i] << " " << b[i].size() << endl;
  28. }
  29. } else if (t == 2){
  30. cout << n << endl;
  31. for (int i = 1; i <= n; ++i){
  32. cout << b[i].size() << " ";
  33. for (auto j : b[i]){
  34. cout << j << " ";
  35. }
  36. cout << endl;
  37. }
  38. }
  39. return 0;
  40. }
Success #stdin #stdout 0.38s 118408KB
stdin
Standard input is empty
stdout
Standard output is empty