Advertisement
GerONSo

Untitled

Feb 17th, 2020
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.52 KB | None | 0 0
  1. /*
  2.  
  3. ∧_∧
  4. ( ・ω・。)つ━☆・*。
  5. ⊂  ノ    ・゜
  6. しーJ   Accepted
  7.  
  8. */
  9.  
  10.  
  11.  
  12. // #pragma GCC optimize("O3")
  13. // #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
  14.  
  15. #include <bits/stdc++.h>
  16. #include <ext/pb_ds/assoc_container.hpp>
  17. #include <ext/pb_ds/tree_policy.hpp>
  18.  
  19. #define ll long long
  20. #define all(x) begin(x), end(x)
  21. #define x first
  22. #define y second
  23. #define int long long
  24.  
  25. using namespace std;
  26. using namespace __gnu_pbds;
  27.  
  28. typedef long double ld;
  29. template<typename T>
  30. using kawaii_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
  31.  
  32. const ld PI = atan2(0, -1);
  33.  
  34. void seriy() {
  35. ios::sync_with_stdio(0);
  36. cin.tie(0);
  37. cout.tie(0);
  38. cout << fixed << setprecision(14);
  39. #ifdef _offline
  40. freopen("input.txt", "r", stdin);
  41. freopen("output.txt", "w", stdout);
  42. #endif
  43. }
  44.  
  45. const int MAXN = 2e5 + 10;
  46. const int MAXM = 600;
  47. const int INF = 1e18 + 7;
  48. const int BASE = 47;
  49. const int MOD = 998244353;
  50. const int MAXLOG = 61;
  51. const ld EPS = 1e-8;
  52.  
  53. signed main() {
  54. seriy();
  55. int n;
  56. cin >> n;
  57. vector<vector<int>> a(n, vector<int>(n)), b(n, vector<int>(n));
  58. for(int i = 0; i < n; i++) {
  59. for(int j = 0; j < n; j++) {
  60. cin >> a[i][j];
  61. }
  62. }
  63. mt19937 rr(time(0));
  64. while(1) {
  65. for(int i = 0; i < n; i++) {
  66. for(int j = 0; j < n; j++) {
  67. b[i][j] = rr() % a[i][j];
  68. }
  69. }
  70. vector<int> dx = {-1, -1, -1, 0, 0, 1, 1, 1};
  71. vector<int> dy = {-1, 0, 1, -1, 1, -1, 0, 1};
  72. bool f = 0;
  73. for(int i = 0; i < n; i++) {
  74. for(int j = 0; j < n; j++) {
  75. int sum = 0;
  76. for(int k = 0; k < 8; k++) {
  77. int tox = i + dx[k];
  78. int toy = j + dy[k];
  79. if(tox > -1 && tox < n && toy > -1 && toy < n) {
  80. sum += b[tox][toy];
  81. }
  82. }
  83. if(sum != a[i][j]) {
  84. f = 1;
  85. break;
  86. }
  87. }
  88. if(f) {
  89. break;
  90. }
  91. }
  92. if(!f) {
  93. for(int i = 0; i < n; i++) {
  94. for(int j = 0; j < n; j++) {
  95. cout << b[i][j] << " ";
  96. }
  97. cout << '\n';
  98. }
  99. return 0;
  100. }
  101. }
  102. return 0;
  103. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement