提出 #33910465
ソースコード 拡げる
#include <bits/stdc++.h>
#include<atcoder/maxflow>
using namespace std;
typedef long long ll;
#define rep(i,a,n) for (ll i=a;i<(ll)n;i++)
ll read(){ll r;scanf("%lld",&r);return r;} // read
int A[110][110];
int main(){
int H = read();
int W = read();
int C = read();
auto enc = [=](int i,int j){return i*W+j;};
atcoder::mf_graph<ll> graph(H*W+2);
rep(i,0,H) rep(j,0,W) A[i][j] = read();
int S = H*W; // 源,同块表示选
int T = S+1; // 汇,同块表示不选
// S->(i,j), 容量A[i][j], 不选
rep(i,0,H) rep(j,0,W) graph.add_edge(S,enc(i,j),A[i][j]);
// (i,j) -> (i-1,j-1), 当前选, 左上不选; (i,j) -> T 当前选,左上不存在
rep(i,0,H) rep(j,0,W) graph.add_edge(enc(i,j),(i && j )?enc(i-1,j-1):T,C);
// (i,j) -> (i-1,j+1), 当前选, 右上不选; (i,j) -> T 当前选,右上不存在
rep(i,0,H) rep(j,0,W) graph.add_edge(enc(i,j),(i && j+1<W)?enc(i-1,j+1):T,C);
ll ans = -graph.flow(S,T);
rep(i,0,H) rep(j,0,W) ans += A[i][j];
printf("%lld\n",ans);
}
提出情報
| 提出日時 |
|
| 問題 |
G - X |
| ユーザ |
cromarmot |
| 言語 |
C++ (GCC 9.2.1) |
| 得点 |
600 |
| コード長 |
1007 Byte |
| 結果 |
AC |
| 実行時間 |
49 ms |
| メモリ |
5636 KiB |
コンパイルエラー
./Main.cpp: In function ‘ll read()’:
./Main.cpp:8:21: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
8 | ll read(){ll r;scanf("%lld",&r);return r;} // read
| ~~~~~^~~~~~~~~~~
ジャッジ結果
| セット名 |
Sample |
All |
| 得点 / 配点 |
0 / 0 |
600 / 600 |
| 結果 |
|
|
| セット名 |
テストケース |
| Sample |
example0.txt, example1.txt, example2.txt |
| All |
000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, 012.txt, 013.txt, 014.txt, 015.txt, 016.txt, 017.txt, 018.txt, 019.txt, 020.txt, 021.txt, 022.txt, 023.txt, 024.txt, 025.txt, 026.txt, 027.txt, 028.txt, 029.txt, 030.txt, 031.txt, 032.txt, 033.txt, 034.txt, 035.txt, 036.txt, 037.txt, 038.txt, 039.txt, 040.txt, 041.txt, 042.txt, 043.txt, 044.txt, 045.txt, 046.txt, 047.txt, 048.txt, 049.txt, 050.txt, 051.txt, 052.txt, 053.txt, 054.txt, 055.txt, example0.txt, example1.txt, example2.txt |
| ケース名 |
結果 |
実行時間 |
メモリ |
| 000.txt |
AC |
12 ms |
5520 KiB |
| 001.txt |
AC |
2 ms |
3636 KiB |
| 002.txt |
AC |
2 ms |
3756 KiB |
| 003.txt |
AC |
2 ms |
3728 KiB |
| 004.txt |
AC |
12 ms |
5536 KiB |
| 005.txt |
AC |
2 ms |
3696 KiB |
| 006.txt |
AC |
2 ms |
3816 KiB |
| 007.txt |
AC |
2 ms |
3696 KiB |
| 008.txt |
AC |
12 ms |
5632 KiB |
| 009.txt |
AC |
12 ms |
5532 KiB |
| 010.txt |
AC |
16 ms |
5524 KiB |
| 011.txt |
AC |
15 ms |
5624 KiB |
| 012.txt |
AC |
5 ms |
4316 KiB |
| 013.txt |
AC |
3 ms |
4272 KiB |
| 014.txt |
AC |
2 ms |
3768 KiB |
| 015.txt |
AC |
2 ms |
3800 KiB |
| 016.txt |
AC |
5 ms |
3968 KiB |
| 017.txt |
AC |
10 ms |
4716 KiB |
| 018.txt |
AC |
2 ms |
3752 KiB |
| 019.txt |
AC |
3 ms |
4192 KiB |
| 020.txt |
AC |
11 ms |
5540 KiB |
| 021.txt |
AC |
12 ms |
5512 KiB |
| 022.txt |
AC |
27 ms |
5524 KiB |
| 023.txt |
AC |
11 ms |
5624 KiB |
| 024.txt |
AC |
49 ms |
5540 KiB |
| 025.txt |
AC |
45 ms |
5528 KiB |
| 026.txt |
AC |
47 ms |
5628 KiB |
| 027.txt |
AC |
46 ms |
5636 KiB |
| 028.txt |
AC |
47 ms |
5404 KiB |
| 029.txt |
AC |
48 ms |
5520 KiB |
| 030.txt |
AC |
47 ms |
5408 KiB |
| 031.txt |
AC |
48 ms |
5564 KiB |
| 032.txt |
AC |
42 ms |
5564 KiB |
| 033.txt |
AC |
46 ms |
5636 KiB |
| 034.txt |
AC |
42 ms |
5532 KiB |
| 035.txt |
AC |
48 ms |
5564 KiB |
| 036.txt |
AC |
12 ms |
5540 KiB |
| 037.txt |
AC |
11 ms |
5456 KiB |
| 038.txt |
AC |
23 ms |
5408 KiB |
| 039.txt |
AC |
14 ms |
5456 KiB |
| 040.txt |
AC |
35 ms |
5536 KiB |
| 041.txt |
AC |
46 ms |
5468 KiB |
| 042.txt |
AC |
32 ms |
5628 KiB |
| 043.txt |
AC |
38 ms |
5632 KiB |
| 044.txt |
AC |
37 ms |
5540 KiB |
| 045.txt |
AC |
35 ms |
5480 KiB |
| 046.txt |
AC |
45 ms |
5512 KiB |
| 047.txt |
AC |
42 ms |
5536 KiB |
| 048.txt |
AC |
38 ms |
5540 KiB |
| 049.txt |
AC |
37 ms |
5404 KiB |
| 050.txt |
AC |
39 ms |
5560 KiB |
| 051.txt |
AC |
36 ms |
5408 KiB |
| 052.txt |
AC |
32 ms |
5512 KiB |
| 053.txt |
AC |
28 ms |
5632 KiB |
| 054.txt |
AC |
31 ms |
5508 KiB |
| 055.txt |
AC |
29 ms |
5564 KiB |
| example0.txt |
AC |
2 ms |
3752 KiB |
| example1.txt |
AC |
2 ms |
3696 KiB |
| example2.txt |
AC |
3 ms |
3680 KiB |