fork download
  1. #include <iostream>
  2. #include <vector>
  3. using namespace std;
  4.  
  5. bool mp[101][101] = {false};
  6. int dx[] = {1, 0, -1, 0};
  7. int dy[] = {0, 1, 0, -1};
  8.  
  9. bool isValid(int x, int y) {
  10. return x >= 0 && x <= 100 && y >= 0 && y <= 100;
  11. }
  12.  
  13. pair<int, int> turn(pair<int, int> o, pair<int, int>& p) {
  14. auto c = make_pair(p.first-o.first, p.second-o.second);
  15. return make_pair(o.first-c.second, o.second+c.first);
  16. }
  17.  
  18. void func(int x, int y, int d, int g) {
  19. vector<pair<int, int>> v;
  20. v.push_back({x, y});
  21. v.push_back({x+dx[d], y+dy[d]});
  22.  
  23. while(g--) {
  24. auto o = v.back();
  25. for(int i = v.size()-2; i >= 0; i--)
  26. v.push_back(turn(o, v[i]));
  27. }
  28.  
  29. for(auto& p : v) {
  30. cout << p.first << "," << p.second << endl;
  31. if(isValid(p.first, p.second))
  32. mp[p.second][p.first] = true;
  33. }
  34. cout << endl;
  35. }
  36.  
  37. int check() {
  38. int result = 0;
  39. for(int y = 0; y < 100; y++) {
  40. for(int x = 0; x < 100; x++)
  41. if(mp[y][x] && mp[y+1][x] && mp[y][x+1] && mp[y+1][x+1])
  42. result++;
  43. }
  44. return result;
  45. }
  46.  
  47. int main() {
  48. int t;
  49. cin >> t;
  50. while(t--) {
  51. int x, y, d, g;
  52. cin >> x >> y >> d >> g;
  53. func(x, 100-y, d, g);
  54. }
  55. cout << check();
  56. return 0;
  57. }
Success #stdin #stdout 0.01s 5520KB
stdin
3
3 3 0 1
4 2 1 3
4 2 2 1
stdout
3,97
4,97
4,96

4,98
4,99
5,99
5,98
6,98
6,97
5,97
5,96
6,96

4,98
3,98
3,99

7