Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- ∧_∧
- ( ・ω・。)つ━☆・*。
- ⊂ ノ ・゜
- しーJ Accepted
- */
- // #pragma GCC optimize("O3")
- // #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
- #include <bits/stdc++.h>
- #include <ext/pb_ds/assoc_container.hpp>
- #include <ext/pb_ds/tree_policy.hpp>
- #define ll long long
- #define all(x) begin(x), end(x)
- #define x first
- #define y second
- #define int long long
- using namespace std;
- using namespace __gnu_pbds;
- typedef long double ld;
- template<typename T>
- using kawaii_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
- const ld PI = atan2(0, -1);
- void seriy() {
- ios::sync_with_stdio(0);
- cin.tie(0);
- cout.tie(0);
- cout << fixed << setprecision(14);
- #ifdef _offline
- freopen("input.txt", "r", stdin);
- freopen("output.txt", "w", stdout);
- #endif
- }
- const int MAXN = 2e5 + 10;
- const int MAXM = 600;
- const int INF = 1e18 + 7;
- const int BASE = 47;
- const int MOD = 998244353;
- const int MAXLOG = 61;
- const ld EPS = 1e-8;
- signed main() {
- seriy();
- int n;
- cin >> n;
- vector<vector<int>> a(n, vector<int>(n)), b(n, vector<int>(n));
- for(int i = 0; i < n; i++) {
- for(int j = 0; j < n; j++) {
- cin >> a[i][j];
- }
- }
- mt19937 rr(time(0));
- while(1) {
- for(int i = 0; i < n; i++) {
- for(int j = 0; j < n; j++) {
- b[i][j] = rr() % a[i][j];
- }
- }
- vector<int> dx = {-1, -1, -1, 0, 0, 1, 1, 1};
- vector<int> dy = {-1, 0, 1, -1, 1, -1, 0, 1};
- bool f = 0;
- for(int i = 0; i < n; i++) {
- for(int j = 0; j < n; j++) {
- int sum = 0;
- for(int k = 0; k < 8; k++) {
- int tox = i + dx[k];
- int toy = j + dy[k];
- if(tox > -1 && tox < n && toy > -1 && toy < n) {
- sum += b[tox][toy];
- }
- }
- if(sum != a[i][j]) {
- f = 1;
- break;
- }
- }
- if(f) {
- break;
- }
- }
- if(!f) {
- for(int i = 0; i < n; i++) {
- for(int j = 0; j < n; j++) {
- cout << b[i][j] << " ";
- }
- cout << '\n';
- }
- return 0;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement