fork download
  1. /*
  2. */
  3.  
  4. //#pragma comment(linker, "/STACK:16777216")
  5. #define _CRT_SECURE_NO_WARNINGS
  6.  
  7. #include <fstream>
  8. #include <iostream>
  9. #include <string>
  10. #include <complex>
  11. #include <math.h>
  12. #include <set>
  13. #include <vector>
  14. #include <map>
  15. #include <queue>
  16. #include <stdio.h>
  17. #include <stack>
  18. #include <algorithm>
  19. #include <list>
  20. #include <ctime>
  21. #include <memory.h>
  22. #include <assert.h>
  23.  
  24. #define y0 sdkfaslhagaklsldk
  25. #define y1 aasdfasdfasdf
  26. #define yn askfhwqriuperikldjk
  27. #define j1 assdgsdgasghsf
  28. #define tm sdfjahlfasfh
  29. #define lr asgasgash
  30.  
  31. #define eps 1e-8
  32. #define M_PI 3.141592653589793
  33. #define bs 1000000007
  34. #define bsize 256
  35.  
  36. const int N = 1500000;
  37.  
  38. using namespace std;
  39.  
  40. vector<vector<int> > generate_board(int sz)
  41. {
  42. if (sz == 1)
  43. {
  44. vector<vector<int> > V;
  45. V.resize(2);
  46. V[0].resize(2);
  47. V[1].resize(2);
  48. V[0][1] = 1;
  49. return V;
  50. }
  51. vector<vector<int> > temp = generate_board(sz - 1);
  52.  
  53. vector<vector<int> > res;
  54. res.resize(temp.size()*2);
  55. for (int i = 0; i < res.size(); i++)
  56. {
  57. res[i].resize(temp.size() * 2);
  58. for (int j = 0; j < res[i].size(); j++)
  59. {
  60. if (i / temp.size() == j / temp.size())
  61. res[i][j] = temp[i%temp.size()][j%temp.size()];
  62. else
  63. {
  64. if (i == 0 && j == temp.size())
  65. {
  66. res[i][j] = 1;
  67. }
  68. else if (i == temp.size() && j == 0)
  69. {
  70. res[i][j] = 0;
  71. }
  72. else
  73. {
  74. res[i][j] = (i > j);
  75. }
  76. }
  77. }
  78. }
  79. return res;
  80. }
  81.  
  82. int main(){
  83. //freopen("route.in","r",stdin);
  84. //freopen("route.out","w",stdout);
  85. //freopen("F:/in.txt", "r", stdin);
  86. //freopen("F:/output.txt", "w", stdout);
  87. ios_base::sync_with_stdio(0);
  88. //cin.tie(0);
  89.  
  90. vector<vector<int> >board = generate_board(4);
  91.  
  92. cout << 16 << endl;
  93.  
  94. for (int i = 0; i < board.size(); i++)
  95. {
  96. for (int j = 0; j < board[i].size(); j++)
  97. {
  98. if (j)
  99. cout << " ";
  100. cout << board[i][j];
  101. }
  102. cout << endl;
  103. }
  104.  
  105.  
  106. cin.get(); cin.get();
  107. return 0;
  108. }
Success #stdin #stdout 0s 3456KB
stdin
Standard input is empty
stdout
16
0 1 1 0 1 0 0 0 1 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0
1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 1 1 1 0 1 1 0 0 0 0 0 0 0 0 0
1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0
1 1 1 1 0 1 0 1 0 0 0 0 0 0 0 0
1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0
0 1 1 1 1 1 1 1 0 1 1 0 1 0 0 0
1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0
1 1 1 1 1 1 1 1 0 1 0 1 0 0 0 0
1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0
1 1 1 1 1 1 1 1 0 1 1 1 0 1 1 0
1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0
1 1 1 1 1 1 1 1 1 1 1 1 0 1 0 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0