https://zerojudge.tw/ShowProblem?problemid=f313```cpp= #include <bits/stdc++.h> using namespace std; /* 2 3 4 1 10 2 -1 5 -1 2 */ int main(){ int r, c, k, m; cin>>r>>c>>k>>m; //int arr[r][c]; vector<vector<int>> arr(r, vector<int>(c)); vector<vector<int>> brr(r, vector<int>(c)); for(int i=0; i<r; i++){ for(int j=0; j<c; j++){ cin>>arr[i][j]; } } while(m--){ brr = arr; for(int i=0; i<r; i++){ for(int j=0; j<c; j++){ if(arr[i][j] == -1 ) continue; int yee = arr[i][j] / k; int cnt = 0; if( i!=0 ){ if(arr[i-1][j] == -1 ) continue; brr[i-1][j] += yee; cnt += yee; } if( i!=(r-1) ){ if(arr[i+1][j] == -1 ) continue; brr[i+1][j] += yee; cnt += yee; } if( j!=0 ){ if(arr[i][j-1] == -1 ) continue; brr[i][j-1] += yee; cnt += yee; } if( j!=(c-1) ){ if(arr[i][j+1] == -1 ) continue; brr[i][j+1] += yee; cnt += yee; } brr[i][j] -= cnt; } } arr = brr; /* cout << "===\n"; for(int i = 0; i < r; ++i) { for(int j = 0; j < c; ++j) cout << arr[i][j] << " "; cout << "\n"; } cout << "===\n\n"; */ } int MAX = 0; int MIN = INT_MAX; for(int i=0; i<r; i++){ for(int j=0; j<c; j++){ if(arr[i][j] == -1 ) continue; MIN = min(MIN, arr[i][j]); MAX = max(MAX, arr[i][j]); // cout<<MIN<<' '<<MAX<<'\n'; } } cout<<MIN<<endl<<MAX; } ```
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up