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. if(isValid(p.first, p.second))
  31. mp[p.second][p.first] = true;
  32. }
  33. }
  34.  
  35. int check() {
  36. int result = 0;
  37. for(int y = 0; y < 50; y++) {
  38. for(int x = 0; x < 50; x++) {
  39. cout << (mp[y][x] ? 1 : 0);
  40. if(mp[y][x] && mp[y+1][x] && mp[y][x+1] && mp[y+1][x+1])
  41. result++;
  42. } cout << endl;
  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, y, d, g);
  54. }
  55. cout << check();
  56. return 0;
  57. }
Success #stdin #stdout 0.01s 5464KB
stdin
4
3 3 0 1
4 2 1 3
4 2 2 1
2 7 3 4
stdout
00000000000000000000000000000000000000000000000000
00011100000000000000000000000000000000000000000000
00011110000000000000000000000000000000000000000000
00111110000000000000000000000000000000000000000000
11111110000000000000000000000000000000000000000000
11100000000000000000000000000000000000000000000000
11000000000000000000000000000000000000000000000000
11100000000000000000000000000000000000000000000000
01100000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000
14