Please sign in first.
提出 #51933262
ソースコード 拡げる
#include <bits/stdc++.h> #define pii pair<int, int> #define piii tuple<int, int, int> #define pll pair<long long, long long> #define L(n) (n << 1) #define R(n) (n << 1 | 1) #define print_vector(n, delimiter) for(auto a0 : n) cout << a0 << delimiter; cout << endl; #define vector_sort(n) sort(n.begin(), n.end()) #define print_array(n, l, r, delimiter) for(int a0 = l; a0 <= r; a0++) cout << n[a0] << delimiter; cout << '\n'; #define REP(i, l, r) for (int i = l; i <= r; i++) #define VREP(i, l, r) for (int i = l; i >= r; i--) #define MIN(a, b) (a < b ? a : b) #define MAX(a, b) (a > b ? a : b) #define ABS(a) ((a) > 0 ? (a) : -(a)) #define LOG2(n) (31 - __builtin_clz(n)) using namespace std; #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; template <class T> using ordered_set = tree<T, null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update>; template<class T> istream & operator >> (istream &in, pair<T, T> &p) { in >> p.first >> p.second; return in; } template<class T> ostream & operator <<(ostream &out, pair<T, T> &p) { out << p.first << ' ' << p.second; return out; } template<class Tuple, std::size_t N> struct TuplePrinter { static void print(ostream &out, const Tuple& t) { TuplePrinter<Tuple, N-1>::print(out, t); out << ' ' << get<N-1>(t); } }; template<class Tuple> struct TuplePrinter<Tuple, 1> { static void print(ostream &out, const Tuple& t) { out << get<0>(t); } }; template<class... Args> ostream & operator <<(ostream &out, const tuple<Args...> &p) { TuplePrinter<decltype(p), sizeof...(Args)>::print(out, p); return out; } const int MAX_N = 1e3; int N, D; int A[MAX_N + 5][MAX_N + 5]; int B[MAX_N + 5][MAX_N + 5]; int C[MAX_N + 5][MAX_N + 5]; void tryAns(int num) { int tot = 0; // vector<piii> ans; for (int i = 1; i <= N; i++) { for (int j = 1; j <= N; j++) { int turun = (B[i][j] + D*4 - num) % (D + D); int naik = (num + D*4 - B[i][j]) % (D + D); if (turun < naik) { C[i][j] = A[i][j] - turun; tot += turun; } else { C[i][j] = A[i][j] + naik; tot += naik; } } } if (tot <= D * N * N / 2) { // cout << ans.size() << "\n"; // print_vector(ans, '\n'); for (int i = 1; i <= N; i++) { for (int j = 1; j <= N; j++) { cout << C[i][j] << " "; } cout << "\n"; } exit(0); } } int32_t main() { ios_base::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]; B[i][j] = (A[i][j] + D * (i + j + 10000)) % (D + D); } } tryAns(0); tryAns(D); }
提出情報
提出日時 | |
---|---|
問題 | A - Adjacent Difference |
ユーザ | Noob_king |
言語 | C++ 17 (gcc 12.2) |
得点 | 600 |
コード長 | 2693 Byte |
結果 | AC |
実行時間 | 32 ms |
メモリ | 9488 KiB |
ジャッジ結果
セット名 | Sample | All | ||||
---|---|---|---|---|---|---|
得点 / 配点 | 0 / 0 | 600 / 600 | ||||
結果 |
|
|
セット名 | テストケース |
---|---|
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 |
ケース名 | 結果 | 実行時間 | メモリ |
---|---|---|---|
01_sample_01.txt | AC | 1 ms | 3528 KiB |
01_sample_02.txt | AC | 1 ms | 3464 KiB |
02_rand_1_01.txt | AC | 1 ms | 3520 KiB |
02_rand_1_02.txt | AC | 1 ms | 3548 KiB |
02_rand_1_03.txt | AC | 1 ms | 3672 KiB |
02_rand_1_04.txt | AC | 1 ms | 3476 KiB |
02_rand_1_05.txt | AC | 1 ms | 3620 KiB |
02_rand_1_06.txt | AC | 6 ms | 5744 KiB |
02_rand_1_07.txt | AC | 4 ms | 5012 KiB |
02_rand_1_08.txt | AC | 17 ms | 7744 KiB |
02_rand_1_09.txt | AC | 19 ms | 7984 KiB |
02_rand_1_10.txt | AC | 10 ms | 6812 KiB |
02_rand_1_11.txt | AC | 31 ms | 9388 KiB |
02_rand_1_12.txt | AC | 30 ms | 9396 KiB |
02_rand_1_13.txt | AC | 31 ms | 9384 KiB |
02_rand_1_14.txt | AC | 32 ms | 9412 KiB |
02_rand_1_15.txt | AC | 31 ms | 9332 KiB |
03_rand_2_01.txt | AC | 1 ms | 3464 KiB |
03_rand_2_02.txt | AC | 1 ms | 3476 KiB |
03_rand_2_03.txt | AC | 1 ms | 3540 KiB |
03_rand_2_04.txt | AC | 1 ms | 3484 KiB |
03_rand_2_05.txt | AC | 1 ms | 3564 KiB |
03_rand_2_06.txt | AC | 4 ms | 5372 KiB |
03_rand_2_07.txt | AC | 5 ms | 5596 KiB |
03_rand_2_08.txt | AC | 8 ms | 6452 KiB |
03_rand_2_09.txt | AC | 1 ms | 3560 KiB |
03_rand_2_10.txt | AC | 9 ms | 6792 KiB |
03_rand_2_11.txt | AC | 27 ms | 9320 KiB |
03_rand_2_12.txt | AC | 27 ms | 9488 KiB |
03_rand_2_13.txt | AC | 27 ms | 9380 KiB |
03_rand_2_14.txt | AC | 29 ms | 9328 KiB |
03_rand_2_15.txt | AC | 29 ms | 9380 KiB |
04_almost_const_01.txt | AC | 28 ms | 9364 KiB |
04_almost_const_02.txt | AC | 25 ms | 9336 KiB |
04_almost_const_03.txt | AC | 24 ms | 9332 KiB |
04_almost_const_04.txt | AC | 25 ms | 9356 KiB |
04_almost_const_05.txt | AC | 25 ms | 9392 KiB |
05_stripe_01.txt | AC | 24 ms | 9340 KiB |
05_stripe_02.txt | AC | 25 ms | 9360 KiB |
05_stripe_03.txt | AC | 26 ms | 9400 KiB |
05_stripe_04.txt | AC | 25 ms | 9312 KiB |
05_stripe_05.txt | AC | 25 ms | 9312 KiB |
05_stripe_06.txt | AC | 25 ms | 9408 KiB |
05_stripe_07.txt | AC | 24 ms | 9348 KiB |
05_stripe_08.txt | AC | 26 ms | 9340 KiB |
06_bfs_01.txt | AC | 25 ms | 9352 KiB |
06_bfs_02.txt | AC | 24 ms | 9268 KiB |
06_bfs_03.txt | AC | 23 ms | 9408 KiB |
06_bfs_04.txt | AC | 23 ms | 9368 KiB |
06_bfs_05.txt | AC | 22 ms | 9412 KiB |
06_bfs_06.txt | AC | 23 ms | 9344 KiB |
06_bfs_07.txt | AC | 23 ms | 9404 KiB |
06_bfs_08.txt | AC | 22 ms | 9304 KiB |
06_bfs_09.txt | AC | 23 ms | 9404 KiB |
06_bfs_10.txt | AC | 23 ms | 9384 KiB |