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

3,97
4,97
4,96

o4,99
p4,98
c0,-1
r5,99

o5,99
p4,99
c-1,0
r5,98

o5,99
p4,98
c-1,-1
r6,98

o6,98
p5,98
c-1,0
r6,97

o6,98
p5,99
c-1,1
r5,97

o6,98
p4,99
c-2,1
r5,96

o6,98
p4,98
c-2,0
r6,96

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

o3,98
p4,98
c1,0
r3,99

4,98
3,98
3,99

4,96
5,96
3,97
4,97
5,97
3,98
4,98
7