This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
# include<bits/stdc++.h>
using namespace std;
struct T{
int x,y;
};
T mov[4]={{0,1},{1,0},{-1,0},{0,-1}};
int main(){
int n,m,a,b,c,mx=0;
cin>>n>>m>>a>>b>>c;
vector<vector<int>>v(n+2,vector<int>(m+2,-1000));
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
cin>>v[i][j];
}
}
queue<T>q;
q.push({a,b});
c=c/2;
while(!q.empty()){
if(c>0){
if(c==1){
T aa=q.front();
q.pop();
for(auto a:mov){
v[aa.x+a.x][aa.y+a.y]=v[aa.x+a.x][aa.y+a.y]+v[aa.x][aa.y];
mx=max(mx,v[aa.x+a.x][aa.y+a.y]);
q.push({aa.x+a.x,aa.y+a.y});
}
}
else{
T aa=q.front();
q.pop();
for(auto a:mov){
v[aa.x+a.x][aa.y+a.y]=v[aa.x+a.x][aa.y+a.y]*2+v[aa.x][aa.y];
q.push({aa.x+a.x+aa.y+a.y});
mx=max(mx,v[aa.x+a.x][aa.y+a.y]);
}
}
}
else{
cout<<mx;
return 0 ;
}
c--;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |