Please sign in first.
Submission #51934974
Source Code Expand
// LUOGU_RID: 153869006
#include <bits/stdc++.h>
using namespace std;
const int N = 505;
int n, d;
int a[N][N], b[N][N];
int main(void) {
ios::sync_with_stdio(0);
cin >> n >> d;
for (int i = 1; i <= n; ++i) for (int j = 1; j <= n; ++j) cin >> a[i][j];
for (int t = 0; t < 2; ++t) {
int tot = 0;
for (int i = 1; i <= n; ++i) for (int j = 1; j <= n; ++j) {
b[i][j] = a[i][j] - (a[i][j] % d + d) % d;
if ((b[i][j] / d % 2 + 2) % 2 != ((i + j) % 2 ^ t)) b[i][j] += d;
tot += abs(a[i][j] - b[i][j]);
}
if (tot <= d * n * n / 2) {
for (int i = 1; i <= n; ++i)
for (int j = 1; j <= n; ++j)
cout << b[i][j] << " \n"[j == n];
return 0;
}
}
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | A - Adjacent Difference |
| User | james1BadCreeper |
| Language | C++ 20 (gcc 12.2) |
| Score | 600 |
| Code Size | 842 Byte |
| Status | AC |
| Exec Time | 31 ms |
| Memory | 5648 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 600 / 600 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | 01_sample_01.txt, 01_sample_02.txt |
| All | 01_sample_01.txt, 01_sample_02.txt, 02_rand_1_01.txt, 02_rand_1_02.txt, 02_rand_1_03.txt, 02_rand_1_04.txt, 02_rand_1_05.txt, 02_rand_1_06.txt, 02_rand_1_07.txt, 02_rand_1_08.txt, 02_rand_1_09.txt, 02_rand_1_10.txt, 02_rand_1_11.txt, 02_rand_1_12.txt, 02_rand_1_13.txt, 02_rand_1_14.txt, 02_rand_1_15.txt, 03_rand_2_01.txt, 03_rand_2_02.txt, 03_rand_2_03.txt, 03_rand_2_04.txt, 03_rand_2_05.txt, 03_rand_2_06.txt, 03_rand_2_07.txt, 03_rand_2_08.txt, 03_rand_2_09.txt, 03_rand_2_10.txt, 03_rand_2_11.txt, 03_rand_2_12.txt, 03_rand_2_13.txt, 03_rand_2_14.txt, 03_rand_2_15.txt, 04_almost_const_01.txt, 04_almost_const_02.txt, 04_almost_const_03.txt, 04_almost_const_04.txt, 04_almost_const_05.txt, 05_stripe_01.txt, 05_stripe_02.txt, 05_stripe_03.txt, 05_stripe_04.txt, 05_stripe_05.txt, 05_stripe_06.txt, 05_stripe_07.txt, 05_stripe_08.txt, 06_bfs_01.txt, 06_bfs_02.txt, 06_bfs_03.txt, 06_bfs_04.txt, 06_bfs_05.txt, 06_bfs_06.txt, 06_bfs_07.txt, 06_bfs_08.txt, 06_bfs_09.txt, 06_bfs_10.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 01_sample_01.txt | AC | 1 ms | 3504 KiB |
| 01_sample_02.txt | AC | 1 ms | 3552 KiB |
| 02_rand_1_01.txt | AC | 1 ms | 3604 KiB |
| 02_rand_1_02.txt | AC | 1 ms | 3632 KiB |
| 02_rand_1_03.txt | AC | 1 ms | 3560 KiB |
| 02_rand_1_04.txt | AC | 1 ms | 3544 KiB |
| 02_rand_1_05.txt | AC | 1 ms | 3624 KiB |
| 02_rand_1_06.txt | AC | 6 ms | 4324 KiB |
| 02_rand_1_07.txt | AC | 3 ms | 3984 KiB |
| 02_rand_1_08.txt | AC | 15 ms | 4988 KiB |
| 02_rand_1_09.txt | AC | 19 ms | 4944 KiB |
| 02_rand_1_10.txt | AC | 9 ms | 4576 KiB |
| 02_rand_1_11.txt | AC | 31 ms | 5472 KiB |
| 02_rand_1_12.txt | AC | 27 ms | 5424 KiB |
| 02_rand_1_13.txt | AC | 31 ms | 5424 KiB |
| 02_rand_1_14.txt | AC | 31 ms | 5456 KiB |
| 02_rand_1_15.txt | AC | 31 ms | 5528 KiB |
| 03_rand_2_01.txt | AC | 1 ms | 3600 KiB |
| 03_rand_2_02.txt | AC | 1 ms | 3480 KiB |
| 03_rand_2_03.txt | AC | 1 ms | 3556 KiB |
| 03_rand_2_04.txt | AC | 1 ms | 3552 KiB |
| 03_rand_2_05.txt | AC | 1 ms | 3472 KiB |
| 03_rand_2_06.txt | AC | 4 ms | 4180 KiB |
| 03_rand_2_07.txt | AC | 5 ms | 4328 KiB |
| 03_rand_2_08.txt | AC | 7 ms | 4464 KiB |
| 03_rand_2_09.txt | AC | 1 ms | 3504 KiB |
| 03_rand_2_10.txt | AC | 9 ms | 4580 KiB |
| 03_rand_2_11.txt | AC | 25 ms | 5512 KiB |
| 03_rand_2_12.txt | AC | 25 ms | 5448 KiB |
| 03_rand_2_13.txt | AC | 25 ms | 5500 KiB |
| 03_rand_2_14.txt | AC | 28 ms | 5452 KiB |
| 03_rand_2_15.txt | AC | 28 ms | 5644 KiB |
| 04_almost_const_01.txt | AC | 24 ms | 5448 KiB |
| 04_almost_const_02.txt | AC | 23 ms | 5416 KiB |
| 04_almost_const_03.txt | AC | 21 ms | 5484 KiB |
| 04_almost_const_04.txt | AC | 22 ms | 5648 KiB |
| 04_almost_const_05.txt | AC | 24 ms | 5412 KiB |
| 05_stripe_01.txt | AC | 21 ms | 5408 KiB |
| 05_stripe_02.txt | AC | 22 ms | 5456 KiB |
| 05_stripe_03.txt | AC | 22 ms | 5456 KiB |
| 05_stripe_04.txt | AC | 21 ms | 5388 KiB |
| 05_stripe_05.txt | AC | 22 ms | 5528 KiB |
| 05_stripe_06.txt | AC | 23 ms | 5416 KiB |
| 05_stripe_07.txt | AC | 22 ms | 5612 KiB |
| 05_stripe_08.txt | AC | 24 ms | 5648 KiB |
| 06_bfs_01.txt | AC | 23 ms | 5456 KiB |
| 06_bfs_02.txt | AC | 22 ms | 5516 KiB |
| 06_bfs_03.txt | AC | 21 ms | 5528 KiB |
| 06_bfs_04.txt | AC | 21 ms | 5404 KiB |
| 06_bfs_05.txt | AC | 20 ms | 5520 KiB |
| 06_bfs_06.txt | AC | 21 ms | 5512 KiB |
| 06_bfs_07.txt | AC | 20 ms | 5416 KiB |
| 06_bfs_08.txt | AC | 19 ms | 5516 KiB |
| 06_bfs_09.txt | AC | 21 ms | 5436 KiB |
| 06_bfs_10.txt | AC | 21 ms | 5524 KiB |