Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- #define loop(i,b,e) for(auto i=b;i<=e;i++)
- const int N=500;
- int n,m,x,y,b[N][N],a[N][N];
- bool isOut(int x,int y) {
- if (x<1 || x>n || y > m || y < 1) return true;
- else return false;
- }
- int main() {
- cin >> n >> m >> x >> y;
- loop(i,1,n+x)
- loop(j,1,m+y)
- cin >> b[i][j];
- loop(i,1,n+x)
- loop(j,1,m+y) {
- if (a[i][j] != 0) continue;
- if (b[i][j] == 0) continue;
- if(isOut(i,j) && !isOut(i-x,j-y))
- a[i-x][j-y] = b[i][j];
- else if(!isOut(i,j) && isOut(i-x,j-y))
- a[i][j] = b[i][j];
- else
- a[i][j] = b[i][j] - a[i-x][j-y];
- }
- loop(i,1,n) {
- loop(j,1,m)
- cout << a[i][j] << " ";
- cout << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement