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

Submission #8137095

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[30][30];
//---------------------------------------------------------------------------------------------------
void _main() {
cin >> H >> W;
rep(y, 0, H) rep(x, 0, W) cin >> A[y][x];

int ans = inf;
rep(sy, 0, H) rep(sx, 0, W) {
int sm = 0;
rep(y, 0, H) rep(x, 0, W) {
int dy = abs(sy - y);
int dx = abs(sx - x);
int d = min(dx, dy);
sm += d * A[y][x];
}
chmin(ans, sm);
}
cout << ans << endl;
}

```

#### Submission Info

Submission Time 2019-10-27 13:58:43+0900 C - 幹線道路 (Trunk Road) hamayanhamayan C++14 (GCC 5.4.1) 100 1739 Byte AC 2 ms 256 KB

#### Judge Result

Score / Max Score 0 / 0 10 / 10 90 / 90
Status
 AC × 2
 AC × 6
 AC × 21
Set Name Test Cases
Sample sample-01.txt, sample-02.txt
Subtask1 sample-01.txt, t1-01.txt, t1-02.txt, t1-03.txt, t1-04.txt, t1-05.txt
Subtask2 sample-01.txt, sample-02.txt, t1-01.txt, t1-02.txt, t1-03.txt, t1-04.txt, t1-05.txt, t2-01.txt, t2-02.txt, t2-03.txt, t2-04.txt, t2-05.txt, t2-06.txt, t2-07.txt, t2-08.txt, t2-09.txt, t2-10.txt, t2-11.txt, t2-12.txt, t2-13.txt, t2-14.txt
Case Name Status Exec Time Memory
sample-01.txt AC 1 ms 256 KB
sample-02.txt AC 1 ms 256 KB
t1-01.txt AC 1 ms 256 KB
t1-02.txt AC 2 ms 256 KB
t1-03.txt AC 1 ms 256 KB
t1-04.txt AC 1 ms 256 KB
t1-05.txt AC 1 ms 256 KB
t2-01.txt AC 2 ms 256 KB
t2-02.txt AC 2 ms 256 KB
t2-03.txt AC 1 ms 256 KB
t2-04.txt AC 1 ms 256 KB
t2-05.txt AC 2 ms 256 KB
t2-06.txt AC 1 ms 256 KB
t2-07.txt AC 1 ms 256 KB
t2-08.txt AC 2 ms 256 KB
t2-09.txt AC 2 ms 256 KB
t2-10.txt AC 2 ms 256 KB
t2-11.txt AC 2 ms 256 KB
t2-12.txt AC 2 ms 256 KB
t2-13.txt AC 2 ms 256 KB
t2-14.txt AC 2 ms 256 KB