結果

問題 No.957 植林
ユーザー comi_likecomi_like
提出日時 2021-05-16 17:52:43
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 2,969 bytes
コンパイル時間 4,503 ms
コンパイル使用メモリ 235,028 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-15 08:35:49
合計ジャッジ時間 12,062 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
testcase_34 RE -
testcase_35 RE -
testcase_36 RE -
testcase_37 RE -
testcase_38 RE -
testcase_39 RE -
testcase_40 RE -
testcase_41 RE -
testcase_42 RE -
testcase_43 RE -
testcase_44 RE -
testcase_45 AC 3 ms
5,376 KB
testcase_46 AC 2 ms
5,376 KB
testcase_47 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#include<atcoder/all>
using namespace atcoder;
typedef long long ll;
const long long INF = 1LL<<60;
const double PI = acos(-1.0);
/*const double PI = atan2(0.0,-1.0)*/
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep1(i,aa,n) for(ll i = aa; i <= (ll)(n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define ar_init(aa,val) rep(i,aa.size()) aa[i]=val;
#define v2d(aa,val1,val2,ini) vector<vector<ll>> aa(val1,vector<ll>(val2,ini));
#define pqe priority_queue<ll>
#define pqeg priority_queue<ll,vector<ll>,greater<ll>>
#define lcin(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define eout(...) COU(__VA_ARGS__);
#define sout(...) SCOU(__VA_ARGS__);
#define scin(...) string __VA_ARGS__;CINT(__VA_ARGS__)
#define lb(aa,val) lower_bound(ALL(aa),val)
#define pb push_back
#define mkp make_pair
ll kaijou(ll e){ll r=1;rep(i,e){r*=(i+1);}return r;}

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}

void COU(){}
template <class Head,class... Tail>
void COU(Head&& head,Tail&&... tail){
    cout<<head<<endl;
    COU(move(tail)...);
}

void SCOU(){}
template <class Head,class... Tail>
void SCOU(Head&& head,Tail&&... tail){
    cout<<head<<" ";
    SCOU(move(tail)...);
}

template <class T = ll>
T IN(){T x;cin>>x;return (x);}

using pii = pair<ll,ll>;
using v2 = vector<vector<ll>>;
using v1 = vector<ll>;
using v2p = vector<vector<pii>>;
using v1p = vector<pii>;
const ll mo=1000000007;
//const ll mo=998244353;

v2 mat_pow(v2 en,ll n){
ll si=en.size();
//n==0のときreturn単位行列
if(n==0){
rep(i,en.size()) rep(k,en.size()){
if(i==k){
en[i][k]=1;
}else{
en[i][k]=0;
}
}
return en; 
}

auto dfs = [&](auto self,ll ko) -> v2 {
if(ko==1){
return en;
}

auto e=self(self,ko/2);
v2d(res,si,si,0);
rep(i,res.size()){
rep(k,res.size()){
rep(m,res.size()){
res[i][k]+=e[i][m]*e[m][k]%mo;
res[i][k]%=mo;
}
}
}
v2d(rr,si,si,0);
if(ko%2){
rep(i,res.size()){
rep(k,res.size()){
rep(m,res.size()){
rr[i][k]+=res[i][m]*en[m][k]%mo;
rr[i][k]%=mo;
}
}
}
return rr;
}
return res;
};

return dfs(dfs,n);
}


ll mod_pow(ll N,ll n){
if(n==0) return 1;
ll hh;
hh=n%2;
int tt=mod_pow(N,n/2);
if(hh==0)return tt%mo*tt%mo;
else {return tt%mo*tt%mo*N%mo;}
}


int main(){

//cout<<fixed<<setprecision(15);

lcin(h,w);
mf_graph<ll> graph(900+h+w+10);
ll s=900+h+w+5;
ll t=900+h+w+4;
rep(i,h){
rep(k,w){
lcin(a);
graph.add_edge(s,300*i+k,a);
graph.add_edge(300*i+k,t,0);
graph.add_edge(300*i+k,900+i,INF);
graph.add_edge(300*i+k,900+h+k,INF);
}
}

ll sum=0;
rep(i,h){
lcin(a);
sum+=a;
graph.add_edge(s,900+i,0);
graph.add_edge(900+i,t,a);
}

rep(k,w){
lcin(a);
sum+=a;
graph.add_edge(s,900+h+k,0);
graph.add_edge(900+h+k,t,a);
}
eout(sum-graph.flow(s,t));
}
0