結果

問題 No.2095 High Rise
ユーザー 沙耶花沙耶花
提出日時 2022-10-07 21:40:38
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 853 bytes
コンパイル時間 5,669 ms
コンパイル使用メモリ 278,464 KB
実行使用メモリ 778,056 KB
最終ジャッジ日時 2023-09-03 00:59:01
合計ジャッジ時間 16,827 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 1 ms
4,384 KB
testcase_12 AC 5 ms
5,172 KB
testcase_13 AC 4 ms
4,952 KB
testcase_14 AC 10 ms
8,076 KB
testcase_15 AC 6 ms
5,704 KB
testcase_16 AC 4 ms
4,740 KB
testcase_17 AC 151 ms
91,096 KB
testcase_18 AC 95 ms
61,376 KB
testcase_19 AC 25 ms
16,828 KB
testcase_20 AC 162 ms
97,676 KB
testcase_21 AC 340 ms
184,672 KB
testcase_22 MLE -
testcase_23 MLE -
testcase_24 MLE -
testcase_25 MLE -
testcase_26 MLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
using mint = modint998244353;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf32 1000000001
#define Inf64 4000000000000000001


int main(){
	
	int N,M;
	cin>>N>>M;
	
	vector a(N,vector<long long>(M));
	rep(i,N){
		rep(j,M){
			cin>>a[i][j];
		}
	}
	
	if(N==1){
		cout<<0<<endl;
		return 0;
		
	}
	
	mcf_graph<long long,long long> G(N*M*2);
	
	rep(i,N){
		rep(j,M){
			if(j!=M-1)G.add_edge(i*M+j,i*M+j+1,1,0);
			if(j!=0)G.add_edge(i*M+j,i*M+j-1,1,0);
			
			G.add_edge(N*M + i*M+j, i*M+j,1,0);
			G.add_edge(i*M+j,N*M+i*M+j,1,a[i][j]);
			if(i!=N-1){
				G.add_edge(N*M+i*M+j, N*M+(i+1)*M+j, 1,a[i+1][j]);
			}
		}
	}
	auto ans = G.flow(0,N*M-1,1);
	cout<<ans.second<<endl;
	//cout<<G.flow(0,N*M-1,1).second<<endl;
	
	return 0;
}
0