結果
問題 | No.2328 Build Walls |
ユーザー | おうどん |
提出日時 | 2023-05-28 15:54:12 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 4,320 bytes |
コンパイル時間 | 1,993 ms |
コンパイル使用メモリ | 180,060 KB |
実行使用メモリ | 12,064 KB |
最終ジャッジ日時 | 2024-06-08 08:51:18 |
合計ジャッジ時間 | 14,110 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
10,624 KB |
testcase_01 | AC | 2 ms
5,376 KB |
testcase_02 | AC | 2 ms
5,376 KB |
testcase_03 | AC | 2 ms
5,376 KB |
testcase_04 | AC | 2 ms
5,376 KB |
testcase_05 | AC | 2 ms
5,376 KB |
testcase_06 | AC | 2 ms
5,376 KB |
testcase_07 | AC | 2 ms
5,376 KB |
testcase_08 | AC | 2 ms
5,376 KB |
testcase_09 | AC | 2 ms
5,376 KB |
testcase_10 | AC | 2 ms
5,376 KB |
testcase_11 | AC | 2 ms
5,376 KB |
testcase_12 | AC | 2 ms
5,376 KB |
testcase_13 | AC | 71 ms
6,016 KB |
testcase_14 | AC | 2,835 ms
5,376 KB |
testcase_15 | AC | 2,467 ms
6,948 KB |
testcase_16 | AC | 63 ms
5,376 KB |
testcase_17 | AC | 1,138 ms
5,376 KB |
testcase_18 | AC | 8 ms
5,376 KB |
testcase_19 | AC | 12 ms
5,376 KB |
testcase_20 | AC | 24 ms
5,376 KB |
testcase_21 | AC | 61 ms
6,016 KB |
testcase_22 | TLE | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
testcase_30 | -- | - |
testcase_31 | -- | - |
testcase_32 | -- | - |
testcase_33 | -- | - |
testcase_34 | -- | - |
testcase_35 | -- | - |
testcase_36 | -- | - |
ソースコード
#include <bits/stdc++.h> #include <chrono> using namespace std; using namespace chrono; #define rep(i,n) for(int i = 0 ; i < (n) ; i++) #define rep1(i,n) for(int i = 1 ; i <= (n) ; i++) #define rrep(i,n) for(int i = (n) - 1 ; i >= 0 ; i--) #define rrep1(i,n) for(int i = (n) ; i > 0 ; i--) using ll = int64_t; using P = pair<int, int>; using PL = pair<ll,ll>; using PD = pair<double,double>; using ld = long double; using vi = vector<int>; using vvi = vector<vector<int>>; using vl = vector<ll>; using vvl = vector<vector<ll>>; using vP = vector<P>; template<typename T> using v = vector<T>; template<typename T> using vv = vector<vector<T>>; template<typename T> using vvv = vector<vector<vector<T>>>; template<typename T> using p_q = priority_queue<T, v<T>, greater<T>>; const int INF = 1001001001; const int INTMAX = (1ll<<31)-1; const ll LINF = (1ll<<62); const ll LLMAX = (1ll<<62) + ((1ll<<62)-1); #define line cout << "================================" << endl; #define Yn(x) ((x) ? "Yes" : "No") #define yn(x) ((x) ? "yes" : "no") #define debug(x) cout << #x" : " << (x) << endl; #define output(x) cout << (x) << endl; #define outs(x) cout << #x << endl; #define mod(n) %(n) #define all(a) (a).begin(),(a).end() #define rall(a) (a).rbegin(),(a).rend() #define m_p(a, b) make_pair(a, b) #define set_time(x) steady_clock::time_point (x) = steady_clock::now() #define p_time(x) duration_cast<milliseconds>(x).count() #define show_time(s, e) cout << "実行時間" << duration_cast<milliseconds>(e-s).count() << "ms\n" template <typename T> bool chmin(T& a, T b){if(a>b){a=b;return 1;}return 0;} template <typename T> bool chmax(T& a, T b){if(a<b){a=b;return 1;}return 0;} ostream& operator<< (ostream& os, P a) {return os << a.first << " , " << a.second;} class alucrex{ public: void vin(vi& a){for(auto& i:a)cin>>i;} void vin(vl& a){for(auto& i:a)cin>>i;} void vin(vP& a){for(auto& x:a)cin>>x.first>>x.second;} void vin1(vi& a){rep1(i,a.size()-1)cin>>a[i];} void vvin(vvi& a){for(auto& i:a)for(auto& j:i)cin>>j;} void vvin(vvl& a){for(auto& i:a)for(auto& j:i)cin>>j;} void vvdes(vvi& a){for(auto& i:a){for(auto& j:i){ cout << j << " ";}puts(""); }} void vvdes(vvl& a){for(auto& i:a){for(auto& j:i){ cout << j << " ";}puts(""); }} template<typename T> void vvd(vv<T>& a){rep(i,a.size()){rep(j,a[i].size()){ cout << a[i][j] << " ";}cout<<endl; }} bool TLE(steady_clock::time_point s, int time = 9800){ steady_clock::time_point e = steady_clock::now(); if(duration_cast<milliseconds>(e - s).count() >= time){puts("TLE");return true;} return false; } ll rui(ll n, int r, ll m = LLMAX) { n %= m; ll res = (r < 2 ? 1 : n); ll cnt = 1; if(r >= 2)for( ; cnt *2 <= r ; cnt *= 2) { res *= res; res %= m; } else cnt = 0; for(int i = 0 ; i < (r - cnt) ; i++) {res *= n; res %= m;} return res; } ll kai(ll n) { //O(N) ll res = 1; for(int i = 2 ; i <= n ; i++) res *= i; return res; } }; const int MOD = 1000000007; int main(){ //set_time(__start__); alucrex al; int h, w; cin >> h >> w; vvi cost(h-2, vi(w)); rep(i, h-2) { rep(j, w) { cin >> cost[i][j]; } } int ans = INF; int di[] = {-1, -1, -1, 0, 0, 1, 1, 1}; int dj[] = {-1, 0, 1, -1, 1, -1, 0, 1}; vvi field(h-2, vi(w, INF)); rep(i, h-2) { if(cost[i][0] == -1) continue; field[i][0] = cost[i][0]; } rep(i, h-2) { queue<P> q; q.push({i, 0}); while(!q.empty()) { P now = q.front(); q.pop(); rep(j, 8) { int ni = now.first, nj = now.second; ni += di[j]; nj += dj[j]; if(ni < 0 || nj <= 0 || ni >= h-2 || nj >= w) continue; if(cost[ni][nj] == -1) continue; if(chmin(field[ni][nj], field[now.first][now.second] + cost[ni][nj])) { q.push({ni, nj}); } } } // line; // al.vvdes(field); rep(i, h-2) chmin(ans, field[i][w-1]); } cout << (ans==INF ? -1 : ans) << endl; //set_time(__end__); //show_time(__start__ , __end__); }