Advertisement
josiftepe

Untitled

Jun 13th, 2021
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. pair<int, int> p[4];
  2. for(int i = 0; i < 4; i++) {
  3. p[i] = make_pair(si, sj);
  4. }
  5. int di[] = {-1, 0, 1, 0};
  6. int dj[] = {0, -1, 0, 1};
  7. int ret = 0;
  8. for(int i = 0; i < 4; i++) {
  9. if(p[i].first + di[i] >= 0 and p[i].first + di[i] < n and p[i].second + dj[i] >= 0 and p[i].second + dj[i] < m) {
  10. p[i].first += di[i];
  11. p[i].second += dj[i];
  12. ret += mat[p[i].first][p[i].second];
  13. }
  14.  
  15. }
  16. int S = ret;
  17. for(int G = 0; G < 60; G++) {
  18. int tmp = S;
  19. for(int i = 0; i < 4; i++) {
  20. if(p[i].first + di[i] >= 0 and p[i].first + di[i] < n and p[i].second + dj[i] >= 0 and p[i].second + dj[i] < m) {
  21. p[i].first += di[i];
  22. p[i].second += dj[i];
  23.  
  24. }
  25. }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement