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. cout << "o" << o.first << "," << o.second << endl;
  15. cout << "p" << p.first << "," << p.first << endl;
  16. auto c = make_pair(p.first-o.first, p.second-o.second);
  17. cout << c.first << "," << c.second << endl << endl;
  18. return make_pair(o.first-c.second, o.second+c.first);
  19. }
  20.  
  21. void func(int x, int y, int d, int g) {
  22. vector<pair<int, int>> v;
  23. v.push_back({x, y});
  24. v.push_back({x+dx[d], y+dy[d]});
  25.  
  26. while(g--) {
  27. auto o = v.back();
  28. for(int i = v.size()-2; i >= 0; i--)
  29. v.push_back(turn(o, v[i]));
  30. }
  31.  
  32. for(auto& p : v) {
  33. cout << p.first << "," << p.second << endl;
  34. if(isValid(p.first, p.second))
  35. mp[p.second][p.first] = true;
  36. }
  37. cout << endl;
  38. }
  39.  
  40. int check() {
  41. int result = 0;
  42. for(int y = 0; y < 100; y++) {
  43. for(int x = 0; x < 100; x++)
  44. if(mp[y][x] && mp[y+1][x] && mp[y][x+1] && mp[y+1][x+1])
  45. result++;
  46. }
  47. return result;
  48. }
  49.  
  50. int main() {
  51. int t;
  52. cin >> t;
  53. while(t--) {
  54. int x, y, d, g;
  55. cin >> x >> y >> d >> g;
  56. func(x, 100-y, d, g);
  57. }
  58. cout << check();
  59. return 0;
  60. }
Success #stdin #stdout 0.01s 5424KB
stdin
3
3 3 0 1
4 2 1 3
4 2 2 1
stdout
o4,97
p3,3
-1,0

3,97
4,97
4,96

o4,99
p4,4
0,-1

o5,99
p4,4
-1,0

o5,99
p4,4
-1,-1

o6,98
p5,5
-1,0

o6,98
p5,5
-1,1

o6,98
p4,4
-2,1

o6,98
p4,4
-2,0

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

o3,98
p4,4
1,0

4,98
3,98
3,99

7