結果
問題 |
No.2855 Move on Grid
|
ユーザー |
|
提出日時 | 2024-08-25 16:05:23 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,467 bytes |
コンパイル時間 | 26,163 ms |
コンパイル使用メモリ | 361,648 KB |
最終ジャッジ日時 | 2025-02-24 01:42:42 |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 11 WA * 29 |
コンパイルメッセージ
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.4.0/include/c++/12/bits/specfun.h:45, from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.4.0/include/c++/12/cmath:1935, from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.4.0/include/c++/12/x86_64-pc-linux-gnu/bits/stdc++.h:41, from main.cpp:4: In static member function 'static constexpr _Up* std::__copy_move<_IsMove, true, std::random_access_iterator_tag>::__copy_m(_Tp*, _Tp*, _Up*) [with _Tp = const long long int; _Up = long long int; bool _IsMove = false]', inlined from 'constexpr _OI std::__copy_move_a2(_II, _II, _OI) [with bool _IsMove = false; _II = const long long int*; _OI = long long int*]' at /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.4.0/include/c++/12/bits/stl_algobase.h:501:30, inlined from 'constexpr _OI std::__copy_move_a1(_II, _II, _OI) [with bool _IsMove = false; _II = const long long int*; _OI = long long int*]' at /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.4.0/include/c++/12/bits/stl_algobase.h:528:42, inlined from 'constexpr _OI std::__copy_move_a(_II, _II, _OI) [with bool _IsMove = false; _II = const long long int*; _OI = long long int*]' at /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.4.0/include/c++/12/bits/stl_algobase.h:535:31, inlined from 'constexpr _OI std::copy(_II, _II, _OI) [with _II = const long long int*; _OI = long long int*]' at /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.4.0/include/c++/12/bits/stl_algobase.h:626:7, inlined from 'static _ForwardIterator std::__uninitialized_copy<true>::__uninit_copy(_InputIterator, _InputIterator, _ForwardIterator) [with _InputIterator = const long long int*; _ForwardIterator = long long int*]' at /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.4.0/include/c++/12/bits/stl_uninitialized.h:147:27, inlined from '_ForwardIterator std::uninitialized_copy(_InputIterator, _InputIterator, _ForwardIterator) [with _InputIterator = const long long int*; _ForwardIterator = long
ソースコード
#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) { if (i >= last.size()) break; last[i] = 1e9; } cout << *min_element(all(last)) << endl; return 0; }