結果
問題 | No.957 植林 |
ユーザー | Katu2ou |
提出日時 | 2024-06-24 21:05:52 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 5,623 bytes |
コンパイル時間 | 4,068 ms |
コンパイル使用メモリ | 241,668 KB |
実行使用メモリ | 27,476 KB |
最終ジャッジ日時 | 2024-06-24 21:06:04 |
合計ジャッジ時間 | 9,352 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
13,756 KB |
testcase_01 | AC | 2 ms
6,816 KB |
testcase_02 | AC | 1 ms
6,816 KB |
testcase_03 | AC | 83 ms
20,432 KB |
testcase_04 | AC | 72 ms
19,380 KB |
testcase_05 | AC | 74 ms
21,020 KB |
testcase_06 | AC | 81 ms
21,992 KB |
testcase_07 | AC | 77 ms
19,880 KB |
testcase_08 | AC | 53 ms
20,644 KB |
testcase_09 | AC | 57 ms
21,016 KB |
testcase_10 | AC | 62 ms
21,636 KB |
testcase_11 | AC | 57 ms
20,900 KB |
testcase_12 | AC | 58 ms
20,684 KB |
testcase_13 | AC | 48 ms
17,988 KB |
testcase_14 | AC | 61 ms
22,400 KB |
testcase_15 | AC | 54 ms
20,524 KB |
testcase_16 | AC | 47 ms
18,296 KB |
testcase_17 | AC | 48 ms
19,556 KB |
testcase_18 | TLE | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
testcase_30 | -- | - |
testcase_31 | -- | - |
testcase_32 | -- | - |
testcase_33 | -- | - |
testcase_34 | -- | - |
testcase_35 | -- | - |
testcase_36 | -- | - |
testcase_37 | -- | - |
testcase_38 | -- | - |
testcase_39 | -- | - |
testcase_40 | -- | - |
testcase_41 | -- | - |
testcase_42 | -- | - |
testcase_43 | -- | - |
testcase_44 | -- | - |
testcase_45 | -- | - |
testcase_46 | -- | - |
testcase_47 | -- | - |
ソースコード
#include <bits/stdc++.h> #include <atcoder/all> using namespace std; using namespace atcoder; #define rep2(i, m, n) for (int i = (m); i < (n); ++i) #define rep(i, n) rep2(i, 0, n) #define drep2(i, m, n) for (int i = (m)-1; i >= (n); --i) #define drep(i, n) drep2(i, n, 0) #define all(...) std::begin(__VA_ARGS__), std::end(__VA_ARGS__) #define rall(...) std::rbegin(__VA_ARGS__), std::rend(__VA_ARGS__) #define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i) #define REV(i, a, b) for (int i = (a); i >= (b); --i) #define CLR(a, b) memset((a), (b), sizeof(a)) #define DUMP(x) cout << #x << " = " << (x) << endl; #define INF 1001001001001001001ll #define inf (int)1001001000 #define MOD 998244353 #define MOD1 1000000007 #define PI 3.14159265358979 #define Dval 1e-12 #define fcout cout << fixed << setprecision(12) #define Mp make_pair #define pb push_back #define fi first #define se second #define SORT(x) sort(x.begin(),x.end()) #define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end()) #define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) #define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) using ll = long long; using ld = long double; using vi = vector<int>; using vl = vector<long long>; using vs = vector<string>; using vd = vector<double>; using vld = vector<long double>; using vc = vector<char>; using vb = vector<bool>; using vpii = vector<pair<int, int>>; using vpil = vector<pair<int, long long>>; using vpll = vector<pair<long long, long long>>; using vvi = vector<vector<int>>; using vvl = vector<vector<long long>>; using vvd = vector<vector<double>>; using vvld = vector<vector<long double>>; using vvc = vector<vector<char>>; using vvb = vector<vector<bool>>; using vvpii = vector<vector<pair<int,int>>>; using vvpll = vector<vector<pair<long long,long long>>>; using vvvi = vector<vector<vector<int>>>; using vvvl = vector<vector<vector<long long>>>; using pii = pair<int, int>; using pll = pair<long long, long long>; using LL = __int128_t; template<typename T> T dgt(T b, T n){ T cnt=0; while(n){ cnt++; n/=b;} return cnt;} ll gcd(ll x, ll y) { if (x == 0) return y; return gcd(y%x, x);} ll lcm(ll x, ll y) { __int128_t xx,yy; xx=x; yy=y; __int128_t ans=xx * yy / gcd(x, y); ll ans2=ans; return ans; } template<typename T> T POW(T x, ll n){T ret=1; while(n>0){ if(n&1) ret=ret*x; x=x*x; n>>=1; } return ret;} template<typename T> T modpow(T a, ll n, T p) { if(n==0) return (T)1; if (n == 1) return a % p; if (n % 2 == 1) return (a * modpow(a, n - 1, p)) % p; T t = modpow(a, n / 2, p); return (t * t) % p;} template<typename T> T modinv(T a, T m) { if(m==0)return (T)1; T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); } u %= m; if (u < 0) u += m; return u;} template<typename T> T REM(T a, T b){ return (a % b + b) % b;} template<typename T> T QUO(T a, T b){ return (a - REM(a, b)) / b;} const int MAXCOMB=510000; ll MODCOMB = 998244353; ll fac[MAXCOMB], finv[MAXCOMB], inv[MAXCOMB]; void COMinit() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (int i = 2; i < MAXCOMB; i++) { fac[i] = fac[i - 1] * i % MODCOMB; inv[i] = MODCOMB - inv[MODCOMB%i] * (MODCOMB / i) % MODCOMB; finv[i] = finv[i - 1] * inv[i] % MODCOMB; }} ll COM(ll n, ll k) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % MODCOMB) % MODCOMB;} ll com(ll n,ll m){ if(n<m || n<=0 ||m<0){ return 0; } if( m==0 || n==m){ return 1; } ll k=1; for(ll i=1;i<=m;i++){ k*=(n-i+1); k%=MODCOMB; k*=modinv(i,MODCOMB); k%=MODCOMB; } return k;} ll rad(ll u, ll p){ ll cnt=0; while(u%p==0){ u/=p; cnt++; } return cnt;} template <typename T> inline bool chmax(T &a, T b) { return ((a < b) ? (a = b, true) : (false));} template <typename T> inline bool chmin(T &a, T b) { return ((a > b) ? (a = b, true) : (false));} template <class T> T BS(vector<T> &vec, T key) { auto itr = lower_bound(vec.begin(), vec.end(), key); return distance(vec.begin(), itr); } template<class T> pair<T,T> RangeBS(vector<T> &vec, T lowv, T highv){auto itr_l = lower_bound(vec.begin(), vec.end(), lowv); auto itr_r = upper_bound(vec.begin(), vec.end(), highv); return make_pair(distance(vec.begin(), itr_l), distance(vec.begin(), itr_r)-1);} void fail() { cout << "-1\n"; exit(0); } void no() { cout << "No\n"; exit(0); } void yes() { cout << "Yes\n"; exit(0); } template<class T> void er(T a) { cout << a << '\n'; exit(0); } int dx[] = { 1,0,-1,0,1,1,-1,-1,0 }; int dy[] = { 0,1,0,-1,1,-1,1,-1,0 }; bool range_in(int i, int j, int h, int w){ if(i<0 || j<0 || i>=h || j>=w) return false; return true;} int bitcount(int n){n=(n&0x55555555)+(n>>1&0x55555555); n=(n&0x33333333)+(n>>2&0x33333333); n=(n&0x0f0f0f0f)+(n>>4&0x0f0f0f0f); n=(n&0x00ff00ff)+(n>>8&0x00ff00ff); n=(n&0x0000ffff)+(n>>16&0x0000ffff); return n;} void solve(int &FIN){ int h,w; cin>>h>>w; vvl cost(h,vl(w)); rep(i,h){ rep(j,w){ cin>>cost[i][j]; } } vl gh(h); vl gw(w); ll ans=0; rep(i,h){ cin>>gh[i]; ans+=gh[i]; } rep(i,w){ cin>>gw[i]; ans+=gw[i]; } mf_graph<ll> G(h*w+2+h+w); rep(i,h*w){ int x=i/w; int y=i%w; G.add_edge(i,h*w+1,cost[x][y]); } rep(i,h){ G.add_edge(h*w,h*w+1+i+1,gh[i]); rep(j,w){ G.add_edge(h*w+1+i+1,i*w+j,INF); } } rep(i,w){ G.add_edge(h*w,h*w+1+h+i+1,gw[i]); rep(j,h){ G.add_edge(h*w+1+h+i+1,j*w+i,INF); } } ll f=G.flow(h*w,h*w+1); cout<<ans-f<<endl; } signed main(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20); int FIN=0; while(1){ solve(FIN); FIN=1; if(FIN)return 0; } }