Advertisement
sandro1234

Untitled

Sep 11th, 2017
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.60 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define fr first
  5. #define sc second
  6. #define MAX ((ll)(1e12+100))
  7. #define ARRS ((ll)(3e5+100))
  8.  
  9. ll a[10][10];
  10.  
  11. ll pas[1000][1000];
  12. ll fr[5][5]={
  13. 1,9,16,-1,10,
  14. 18,4,22,19,5,
  15. 24,14,11,8,15,
  16. 2,20,17,3,21,
  17. 12,7,23,13,6
  18. };
  19. ll gd[5][5]={
  20. 1,17,24,2,18,
  21. 22,14,5,21,13,
  22. 25,8,11,16,7,
  23. 4,20,23,3,19,
  24. 10,15,6,9,12
  25. };
  26. ll gr[5][5]={
  27. 1,9,25,2,10,
  28. 14,17,5,13,16,
  29. 7,23,20,8,24,
  30. 4,12,15,3,11,
  31. 21,18,6,22,19
  32. };
  33. ll glh[5][5]={
  34. 21,18,6,22,19,
  35. 4,12,15,3,11,
  36. 7,23,20,8,24,
  37. 14,17,5,13,16,
  38. 1,9,25,2,10
  39. };
  40. ll gup[5][5]={
  41. 12,9,6,15,10,
  42. 19,3,23,20,4,
  43. 7,16,11,8,25,
  44. 13,21,5,14,22,
  45. 18,2,24,17,1
  46. };
  47. ll gdl[5][5]={
  48. 12,9,6,13,10,
  49. 20,3,16,19,4,
  50. 7,23,11,8,24,
  51. 15,18,5,14,17,
  52. 21,2,25,22,1
  53. };
  54. ll gdr[5][5]={
  55. 21,18,6,22,19,
  56. 4,12,15,3,11,
  57. 7,23,20,8,24,
  58. 14,17,5,13,16,
  59. 1,9,25,2,10
  60. };
  61. ll gdu[5][5]={
  62. 10,15,6,9,12,
  63. 4,20,23,3,19,
  64. 25,8,11,16,7,
  65. 22,14,5,21,13,
  66. 1,17,24,2,18,
  67. };
  68. ll glf[5][5]={
  69. 17,25,6,18,15,
  70. 11,3,21,12,4,
  71. 23,8,16,24,7,
  72. 20,13,5,19,14,
  73. 10,2,22,9,1
  74. };
  75. ll ooo[5][10]={
  76. 43,37,50,42,11,31,24,18,32,23,
  77. 8,40,45,35,6,46,13,21,4,16,
  78. 49,28,10,38,29,26,2,30,25,19,
  79. 44,36,7,41,12,34,5,17,33,22,
  80. 9,39,48,27,1,47,14,20,3,15
  81. };
  82. ll oow[5][10]={
  83. 15,50,26,16,11,25,17,34,24,44,
  84. 8,30,13,48,6,32,22,46,4,21,
  85. 27,39,10,28,40,37,2,43,18,35,
  86. 14,49,7,31,12,47,5,33,23,45,
  87. 9,29,41,38,1,42,19,36,3,20
  88. };
  89. ll g1[5][5]={
  90. 18,2,24,17,1,
  91. 13,21,5,14,22,
  92. 7,16,11,8,25,
  93. 19,3,23,20,4,
  94. 12,9,6,15,10
  95. };
  96. ll g2[5][5]={
  97. 21,2,25,22,1,
  98. 15,18,5,14,17,
  99. 7,23,11,8,24,
  100. 20,3,16,19,4,
  101. 12,9,6,13,10
  102. };
  103. ll g3[5][5]={
  104. 18,2,24,17,1,
  105. 13,21,5,14,22,
  106. 7,16,11,8,25,
  107. 19,3,23,20,4,
  108. 12,9,6,15,10
  109. };
  110. ll g4[5][5]={
  111. 19,11,25,18,10,
  112. 6,3,15,7,4,
  113. 13,23,20,12,24,
  114. 16,8,5,17,9,
  115. 21,2,14,22,1
  116. };
  117. ll gfk[5][5]={
  118. 17,25,6,18,15,
  119. 11,3,21,12,4,
  120. 23,8,16,24,7,
  121. 20,13,5,19,14,
  122. 10,2,22,9,1
  123. };
  124. ll ps5[5][5]={
  125. 1,9,18,2,10,
  126. 20,4,24,21,5,
  127. 17,14,11,8,15,
  128. 25,22,19,3,23,
  129. 12,7,16,13,6,
  130. };
  131.  
  132.  
  133. ll C;
  134. void put(ll x,ll y,ll a[5][5]){
  135. for(int i=0; i<5; i++){
  136. for(int j=0; j<5; j++){
  137. pas[x+i][y+j]=a[i][j]+C;
  138. }
  139. }
  140. C+=25;
  141. }
  142. void put(ll x,ll y,ll a[5][10]){
  143. for(int i=0; i<5; i++){
  144. for(int j=0; j<10; j++){
  145. pas[x+i][y+j]=a[i][j]+C;
  146. }
  147. }
  148. C+=50;
  149. }
  150.  
  151.  
  152. int main(){
  153. ll n;
  154. cin>>n;
  155. ll m=n/5;
  156. if(n==5){
  157. put(0,0,ps5);
  158. for(int i=0; i<n; i++){
  159. for(int j=0; j<n; j++){
  160. cout<<pas[i][j]<<" ";
  161. }
  162. cout<<endl;
  163. }
  164. return 0;
  165. }
  166. if(n==10){
  167. ll pas[10][10]={
  168. 1,52,29,8,51,28,9,50,37,16,85,95,59,86,94,66,87,93,65,88,40,19,100,39,18,76,38,17,77,49,2,53,30,7,58,27,10,89,36,15,84,96,60,75,99,67,72,92,64,71,41,20,82,44,23,90,45,24,78,48,3,54,31,6,57,26,11,68,35,14,83,97,61,74,98,62,73,91,63,70,42,21,81,43,22,80,46,25,79,47,4,55,32,5,56,33,12,69,34,13,};
  169. for(int i=0; i<n; i++){
  170. for(int j=0; j<n; j++){
  171. cout<<pas[i][j]<<" ";
  172. }
  173. cout<<endl;
  174. }
  175. return 0;
  176. }
  177. C=0;
  178. for(int i=0; i<5; i++){
  179. for(int j=0; j<5; j++){
  180. if(fr[i][j]!=-1)
  181. pas[i][j]=C+fr[i][j];
  182. }
  183. }
  184. C+=24;
  185. for(int i=1; i<m-1; i++){
  186. for(int x=i*5; x<i*5+5; x++){
  187. for(int y=0; y<5; y++){
  188. pas[x][y]=gd[x-i*5][y]+C;
  189. }
  190. }
  191. C+=25;
  192. }
  193. for(int i=0; i<m-1; i++){
  194. for(int x=0; x<5; x++){
  195. for(int y=i*5; y<i*5+5; y++){
  196. pas[(m-1)*5+x][y]=gr[x][y-i*5]+C;
  197. }
  198. }
  199. C+=25;
  200. }
  201. put((m-1)*5,(m-1)*5,gd);
  202.  
  203. for(int k=0; k<(m-2)/2; k++){
  204. put((m-2-k*2)*5,(m-1)*5,glh);
  205. for(int t=0; t<m-3; t++){
  206. put((m-2-k*2)*5,(m-2-t)*5,gdl);
  207. }
  208. put((m-2-k*2)*5,5,gup);
  209. put((m-3-k*2)*5,5,gdl);
  210. for(int t=0; t<m-3; t++){
  211. put((m-3-k*2)*5,(t+2)*5,gdr);
  212. }
  213. put((m-3-k*2)*5,(m-1)*5,gdu);
  214. }
  215.  
  216. if(m%2==0){
  217. put(0,(m-1)*5,glh);
  218. for(int t=0; t<m-3; t++){
  219. put(0,(m-2-t)*5,gdl);
  220. }
  221. put(0,5,glf);
  222. }
  223. else {
  224. put(5,(m-1)*5,glh);
  225. put(5,(m-2)*5,gup);
  226.  
  227. if(n==15){
  228. put(0,(m-2)*5,oow);
  229.  
  230. }
  231. else{
  232. put(0,(m-2)*5,ooo);
  233.  
  234. for(int i=0; i<(m-3-2)/2; i++){
  235. put(0,(m-3-i*2)*5,g1);
  236. put(5,(m-3-i*2)*5,g2);
  237. put(5,(m-4-i*2)*5,g3);
  238. put(0,(m-4-i*2)*5,g4);
  239. }
  240. put(0,10,g1);
  241. put(5,10,g2);
  242. put(5,5,g3);
  243. put(0,5,gfk);
  244. }
  245. }
  246.  
  247.  
  248.  
  249. pas[0][3]=C+1;
  250. for(int i=0; i<n; i++){
  251. for(int j=0; j<n; j++){
  252. cout<<pas[i][j]<<" ";
  253. }
  254. cout<<endl;
  255. }
  256. return 0;
  257.  
  258.  
  259. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement