Contest Duration: - (local time) (180 minutes) Back to Home

Submission #8137468

Source Code Expand

Copy
```#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
∧＿∧
∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
（ ´_ゝ`）　/　 ⌒i     @hamayanhamayan
／　　　＼　 　  |　|
/　　 /￣￣￣￣/　　|
＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/

int H, W, A[40][40];
int dp[40][40][1010];
int dx[4] = { 0, 1, 0, -1 }, dy[4] = { -1, 0, 1, 0 };
//---------------------------------------------------------------------------------------------------
void _main() {
cin >> H >> W;
rep(y, 0, H) rep(x, 0, W) cin >> A[y][x];

rep(y, 0, H) rep(x, 0, W) rep(d, 0, H * W) dp[x][y][d] = inf;
dp[0][0][0] = 0;

rep(d, 0, H * W) rep(x, 0, W) rep(y, 0, H) {
rep(di, 0, 4) {
int xx = x + dx[di];
int yy = y + dy[di];
if (0 <= xx and xx < W and 0 <= yy and yy < H) {
int c = dp[x][y][d] + A[yy][xx] * (1 + 2 * d);
chmin(dp[xx][yy][d + 1], c);
}
}
}

int ans = inf;
rep(d, 0, H * W) chmin(ans, dp[W - 1][H - 1][d]);
cout << ans << endl;
}

```

#### Submission Info

Submission Time 2019-10-27 14:06:07+0900 E - 森林伐採（Deforestation） hamayanhamayan C++14 (GCC 5.4.1) 100 2018 Byte AC 17 ms 5888 KB

#### Judge Result

Score / Max Score 0 / 0 15 / 15 28 / 28 57 / 57
Status
 AC × 3
 AC × 17
 AC × 11
 AC × 44
Set Name Test Cases
Sample sample-01.txt, sample-02.txt, sample-03.txt
subtask1 sample-01.txt, sample-02.txt, sample-03.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 01-11.txt, 01-12.txt, 01-13.txt, 01-14.txt
subtask2 sample-01.txt, 02-01.txt, 02-02.txt, 02-03.txt, 02-04.txt, 02-05.txt, 02-06.txt, 02-07.txt, 02-08.txt, 02-09.txt, 02-10.txt
subtask3 sample-01.txt, sample-02.txt, sample-03.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 01-11.txt, 01-12.txt, 01-13.txt, 01-14.txt, 02-01.txt, 02-02.txt, 02-03.txt, 02-04.txt, 02-05.txt, 02-06.txt, 02-07.txt, 02-08.txt, 02-09.txt, 02-10.txt, 03-01.txt, 03-02.txt, 03-03.txt, 03-04.txt, 03-05.txt, 03-06.txt, 03-07.txt, 03-08.txt, 03-09.txt, 03-10.txt, 03-11.txt, 03-12.txt, 03-13.txt, 03-14.txt, 03-15.txt, 03-16.txt, 03-17.txt
Case Name Status Exec Time Memory
01-01.txt AC 1 ms 384 KB
01-02.txt AC 1 ms 384 KB
01-03.txt AC 1 ms 384 KB
01-04.txt AC 1 ms 384 KB
01-05.txt AC 1 ms 384 KB
01-06.txt AC 1 ms 384 KB
01-07.txt AC 1 ms 384 KB
01-08.txt AC 1 ms 256 KB
01-09.txt AC 1 ms 256 KB
01-10.txt AC 1 ms 256 KB
01-11.txt AC 1 ms 384 KB
01-12.txt AC 1 ms 384 KB
01-13.txt AC 1 ms 384 KB
01-14.txt AC 1 ms 384 KB
02-01.txt AC 11 ms 5632 KB
02-02.txt AC 11 ms 3840 KB
02-03.txt AC 15 ms 5888 KB
02-04.txt AC 11 ms 5632 KB
02-05.txt AC 11 ms 3840 KB
02-06.txt AC 15 ms 5888 KB
02-07.txt AC 2 ms 4352 KB
02-08.txt AC 1 ms 384 KB
02-09.txt AC 2 ms 4352 KB
02-10.txt AC 1 ms 384 KB
03-01.txt AC 12 ms 5632 KB
03-02.txt AC 12 ms 3840 KB
03-03.txt AC 17 ms 5888 KB
03-04.txt AC 14 ms 5888 KB
03-05.txt AC 14 ms 5888 KB
03-06.txt AC 17 ms 5888 KB
03-07.txt AC 16 ms 5888 KB
03-08.txt AC 2 ms 4352 KB
03-09.txt AC 1 ms 384 KB
03-10.txt AC 17 ms 5888 KB
03-11.txt AC 17 ms 5888 KB
03-12.txt AC 17 ms 5888 KB
03-13.txt AC 17 ms 5888 KB
03-14.txt AC 17 ms 5888 KB
03-15.txt AC 17 ms 5888 KB
03-16.txt AC 16 ms 5888 KB
03-17.txt AC 17 ms 5888 KB
sample-01.txt AC 1 ms 256 KB
sample-02.txt AC 1 ms 256 KB
sample-03.txt AC 1 ms 256 KB