fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define pb push_back
  4. #define MOD 1000000007
  5. #define PI 4 * atan(1)
  6. #define sz(A) (int)A.size()
  7. typedef long long ll;
  8. typedef vector<int> vi;
  9. typedef pair<int, int> pii;
  10. typedef vector<long long> vll;
  11. typedef long int int32;
  12. typedef unsigned long int uint32;
  13. typedef long long int int64;
  14. typedef unsigned long long int uint64;
  15. int n,e;
  16. set<int> adj[10004];
  17. inline void solve(int test){
  18. int t; cin >> t;
  19. int n; cin >> n;
  20. int a[n+1][n+1] = {0};
  21. for(int i=1; i<=n;i++){
  22. for(int j=1; j<=n; j++) cin >> a[i][j];
  23. }
  24. if(t == 1){
  25. for(int i=1; i<=n; i++){
  26. int c = 0;
  27. for(int j=1; j <=n; j++) c += a[i][j];
  28. cout << c << " ";
  29. }
  30. }else{
  31. vector<pii> vt;
  32. for(int i=1; i<=n; i++){
  33. for(int j=i; j <=n; j++){
  34. if(a[i][j]) vt.push_back({i,j});
  35. }
  36. }
  37. cout << n << " " << vt.size() << "\n";
  38. for(auto it : vt){
  39. cout << it.first << " " << it.second << "\n";
  40. }
  41. }
  42. }
  43. int main(){
  44. ios_base::sync_with_stdio(false);
  45. cin.tie(NULL);
  46. cout.tie(NULL);
  47. int typetest = 0;
  48. if (typetest){
  49. int t;
  50. cin >> t;
  51. cin.ignore();
  52. for(int i=1; i<=t; i++){
  53. solve(i);
  54. }
  55. }
  56. else solve(0);
  57. }
Success #stdin #stdout 0.01s 5324KB
stdin
Standard input is empty
stdout
0 0