fork download
  1. #include <iostream>
  2. #include <vector>
  3. using namespace std;
  4.  
  5. const int dx[] = {1, 0, -1, 0};
  6. const int dy[] = {0, -1, 0, 1};
  7.  
  8. bool mp[101][101] = {0};
  9. void func(int x, int y, int d, int g) {
  10. vector<int> v;
  11. v.push_back(d);
  12. while(g--) {
  13. for(int i = v.size()-1; i >= 0; i--)
  14. v.push_back((d+1)%4);
  15. }
  16.  
  17. mp[y][x] = true;
  18. for(auto& p : v) {
  19. y += dy[p];
  20. x += dx[p];
  21. mp[y][x] = true;
  22. }
  23. }
  24.  
  25. int main() {
  26. int t;
  27. cin >> t;
  28. while(t--) {
  29. int x, y, d, g;
  30. cin >> x >> y >> d >> g;
  31. func(x, y, d, g);
  32. }
  33.  
  34. int result = 0;
  35. for(int i = 0; i < 100; i++) {
  36. for(int j = 0; j < 100; j++)
  37. if(mp[i][j] && mp[i+1][j] && mp[i][j+1] && mp[i+1][j+1])
  38. result++;
  39. }
  40. cout << result;
  41. return 0;
  42. }
Success #stdin #stdout 0.01s 5476KB
stdin
3
3 3 0 1
4 2 1 3
4 2 2 1
stdout
2