fork download
  1. #include<iostream>
  2. #include<algorithm>
  3. #include<cstring>
  4. #include<math.h>
  5. #include<iomanip>
  6. #include<queue>
  7. #define PI acos(-1)
  8. #include<algorithm>
  9. #include<string>
  10. #include<sstream>
  11. #include<vector>
  12. #include<map>
  13. #include<unordered_map>
  14. #include<deque>
  15. #include<limits>
  16. #include<stack>
  17. #include<set>
  18. #include<unordered_set>
  19. #include<cmath>
  20. #include<cstring>
  21. #include<string.h>
  22. #include<ctype.h>
  23. #include<numeric>
  24. #include<stdexcept>
  25. #define rep(i,a,b) for(int i=a ; i<b ; i++)
  26. #define ll long long
  27.  
  28.  
  29. using namespace std;
  30.  
  31. const int N = 2e5+5;
  32. const int M = 1e9 +7;
  33.  
  34. vector<int> g[N];
  35. vector<bool> vis(N,0);
  36. vector<int> h(N,0);
  37. vector<int> num(N,0);
  38.  
  39. void bfs(int node){
  40. //cout<<node<<" "<<no<<'\n';
  41.  
  42. queue<int> q;
  43. q.push(node);
  44. vis[node] = 1;
  45. num[node] = 1;
  46. while( !q.empty() ){
  47. int n = q.front();
  48. q.pop();
  49.  
  50. for(int child: g[n]){
  51. //cout<<child<<" "<<h[child]<<" "<<num[child]<<"{}\n";
  52. if( !vis[child]){
  53. vis[child] = 1;
  54. q.push(child);
  55. num[child] = num[n];
  56. h[child] = h[n]+1;
  57. }
  58. else if( h[n]+1 == h[child]){
  59. num[child] = (num[child]%M +num[n]%M)%M;
  60. }
  61. }
  62. }
  63. return;
  64. }
  65.  
  66.  
  67.  
  68. int main(){
  69. int r , co, x;
  70. cin >> r >> co;
  71. char grid[r][co];
  72. cin >> x;
  73. for(int i = 0 ; i < r ;i++){
  74. for(int j = 0 ; j < co ; j++){
  75. grid[i][j] = ' ';
  76. }
  77. }
  78. while(x--){
  79. char o;
  80. cin >> o;
  81. if( o == 'L'){
  82. int a , b , c , d;
  83. cin >> a >> b >> c >> d;
  84.  
  85. if( a == c ){
  86. if( b > d)swap(b,d);
  87. for(int i = b ; i <= d ; i++){
  88. grid[a][i] = '*';
  89. }
  90. }
  91. else if( b == d){
  92. if( a > c)swap(a,c);
  93. for(int i = a ; i <= c ; i++){
  94. grid[i][b] = '*';
  95. }
  96. }
  97. else{
  98. for(int i = min(a,c) ; i <= max(a,c) ;i++){
  99. grid[i][i] = '*';
  100. }
  101. }
  102. }
  103. else if( o == 'R'){
  104. int a , b , c , d;
  105. cin >> a >> b >> c >> d;
  106. for(int i = a ; i <= c ; i++){
  107. grid[a][i] = '*';
  108. grid[c][i] = '*';
  109. }
  110. for(int i = a ; i <= c ; i++){
  111. grid[i][a] = '*';
  112. grid[i][c] = '*';
  113. }
  114. }
  115. else if(o == 'F'){
  116. char a;
  117. int b , c;
  118. cin >> a >> b >> c;
  119. for(int i = 0 ; i < r ; i++){
  120. for(int j = 0 ; j < co ; j++){
  121. if( grid[i][j] =='*')continue;
  122. else if( i == b and j == c)continue;
  123. else grid[i][j] = a;
  124. }
  125. }
  126. }
  127. }
  128. for(int i = 0 ; i < r ; i++){
  129. for(int j = 0 ; j < co ;j++ )
  130. cout<<grid[i][j];
  131. cout<<'\n';
  132. }
  133. }
  134.  
  135.  
Success #stdin #stdout 0.01s 9400KB
stdin
10 10
3
L 2 2 4 4
R 2 2 5 6
F r 3 4
stdout
rrrrrrrrrr
rrrrrrrrrr
rr****rrrr
rr** *rrrr
rr*r**rrrr
rr****rrrr
rrrrrrrrrr
rrrrrrrrrr
rrrrrrrrrr
rrrrrrrrrr