結果
問題 | No.2855 Move on Grid |
ユーザー | ルク |
提出日時 | 2024-08-25 16:01:08 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,418 bytes |
コンパイル時間 | 7,206 ms |
コンパイル使用メモリ | 314,300 KB |
実行使用メモリ | 218,496 KB |
最終ジャッジ日時 | 2024-08-25 16:02:14 |
合計ジャッジ時間 | 57,067 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | WA | - |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | RE | - |
testcase_11 | RE | - |
testcase_12 | RE | - |
testcase_13 | RE | - |
testcase_14 | RE | - |
testcase_15 | RE | - |
testcase_16 | RE | - |
testcase_17 | RE | - |
testcase_18 | RE | - |
testcase_19 | RE | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | WA | - |
testcase_35 | WA | - |
testcase_36 | WA | - |
testcase_37 | WA | - |
testcase_38 | WA | - |
testcase_39 | WA | - |
ソースコード
#pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include <bits/stdc++.h> #if __has_include(<atcoder/all>) #include <atcoder/all> using namespace atcoder; #endif #include <chrono> #include <unistd.h> using namespace std; using namespace chrono; #define rep(i, n) for (ll i = 0; i < (n); ++i) #define rep1(i, n) for (ll i = 1; i <= (n); ++i) #define rrep(i, n) for (ll i = n; i > 0; --i) #define bitrep(i, n) for (ll i = 0; i < (1 << n); ++i) #define all(a) (a).begin(), (a).end() #define yesNo(b) ((b) ? "Yes" : "No") using ll = long long; using ull = unsigned long long; using ld = long double; using mint = modint998244353; using MINT = modint1000000007; string alphabet = "abcdefghijklmnopqrstuvwxyz"; string ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; constexpr double pi = 3.141592653589793; constexpr ll smallMOD = 998244353; constexpr ll bigMOD = 1000000007; constexpr ll dx[] = {1, 0, -1, 0, 1, -1, -1, 1}; constexpr ll dy[] = {0, 1, 0, -1, 1, 1, -1, -1}; struct Init { Init() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(15); } } init; template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) { os << "["; rep(i, vec.size()) { os << vec[i]; if (i != vec.size() - 1) os << ", "; } os << "]"; return os; } template <typename T> ostream &operator<<(ostream &os, const vector<vector<T>> &vec) { os << "["; rep(i, vec.size()) { os << vec[i]; if (i != vec.size() - 1) os << ", "; } os << "]"; return os; } // graph_template struct Edge { ll to; ll cost; Edge(ll to, ll cost) : to(to), cost(cost) {} bool operator>(const Edge &e) const { return cost > e.cost; } }; int main() { ll n, m, k; cin >> n >> m >> k; vector<vector<ll>> mp(n, vector<ll>(m, 0)); rep(i, n) { rep(j, m) { cin >> mp[i][j]; } } // 右にm個、下にn個移動したときのパス. vector<vector<vector<ll>>> dp(n, vector<vector<ll>>(m, vector<ll>())); dp[0][0] = {mp[0][0]}; rep1(i, n - 1) { vector<ll> tmp = dp[i - 1][0]; tmp.push_back(mp[i][0]); sort(all(tmp)); dp[i][0] = tmp; } rep1(j, m - 1) { vector<ll> tmp = dp[0][j - 1]; tmp.push_back(mp[0][j]); sort(all(tmp)); dp[0][j] = tmp; } rep(i, n) { rep(j, m) { if (i == 0 || j == 0) continue; vector<ll> tmp1 = dp[i - 1][j]; vector<ll> tmp2 = dp[i][j - 1]; ll addNum = mp[i][j]; tmp1.push_back(addNum); tmp2.push_back(addNum); sort(all(tmp1)); sort(all(tmp2)); ll t1 = 1e9, t2 = 1e9; rep(i, tmp1.size()) { if (i < k) break; t1 = min(t1, tmp1[i]); t2 = min(t2, tmp2[i]); } if (t1 < t2) { dp[i][j] = tmp1; } else { dp[i][j] = tmp2; } } } vector<ll> last = dp[n - 1][m - 1]; sort(all(last)); rep(i, k) { last[i] = 1e9; } cout << *min_element(all(last)) << endl; return 0; }