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 <iostream>
#include <vector>
using namespace std;
int main()
{
long m,n;
cin>>m>>n;
vector<vector<int>> a;
long k;
int x,y;
for(int i=0; i<m; i++)
{
for(int j=0; j<n; j++)
{
cin>>x;
a[i].push_back(x);
}
}
cin>>k;
vector<int>r;
vector<int>c;
long zbir=0;
for(int i=0; i<k; i++)
{
cin>>x>>y;
r.push_back(x);
c.push_back(y);
}
for(int i=0; i<k; i++)
{
if((r[i]==m-1 && c[i]==n-1)
||(r[i]==m-1 && c[i]==0)
||(r[i]==0 && c[i]==n-1)
||(r[i]==0 && c[i]==0))
{
cout<<"No"<<endl;
return 0;
}
else if(r[i]==0)
{
zbir+=a[r[i]][c[i]]+a[r[i]][c[i-1]]
+a[r[i]][c[i+1]]+a[r[i+1]][c[i]];
}
else if(r[i]==m-1)
{
zbir+=a[r[i]][c[i]]+a[r[i]][c[i-1]]
+a[r[i]][c[i+1]]+a[r[i-1]][c[i]];
}
else if(c[i]==0)
{
zbir+=a[r[i]-1][c[i]]+a[r[i]][c[i]]
+a[r[i]+1][c[i]]+a[r[i]][c[i]+1];
}
}
return 0;
}
# | 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... |