fork download
  1. //============================================================================
  2. // Name : test3.cpp
  3. // Author :
  4. // Version :
  5. // Copyright : Your copyright notice
  6. // Description : Hello World in C++, Ansi-style
  7. //============================================================================
  8.  
  9. #include <bits/stdc++.h>
  10. using namespace std;
  11.  
  12. int counm=0;
  13. int n , m;
  14. string cnt[100][100];
  15. void checky(int x,int y){
  16. bool check=false;
  17. if (x>=0&&x<n&&y>=0&&y<m&&cnt[x][y]=="Y"){
  18. cnt[x][y]="X";
  19. checky(x+1,y+1);
  20. check=true;
  21. }
  22. if (x>=0&&x<n&&y>=0&&y<m&&cnt[x][y]=="G"){
  23. cnt[x][y]="B";
  24. checky(x+1,y+1);
  25. check=true;
  26. }
  27.  
  28. if(check){
  29. counm++;
  30. }
  31.  
  32. }
  33.  
  34. void checkb(int x,int y){
  35. bool check=false;
  36. if (x>=0&&x<n&&y>=0&&y<m&&cnt[x][y]=="B"){
  37. cnt[x][y]="X";
  38. checky(x+1,y-1);
  39. check=true;
  40. }
  41. if(check){
  42. counm++;
  43. }
  44. }
  45.  
  46. int main() {
  47. scanf("%d%d",&n,&m);
  48.  
  49. for (int i=0;i<n;i++){
  50. for(int j=0;j<n;j++){
  51. scanf("%c",&cnt[i][j]);
  52. }
  53. }
  54. //printf("%d\n",counm);
  55. printf("hello");
  56. for(int i=0;i<n;i++){
  57. for(int j=0;j<n;j++){
  58. checky(i,j);
  59. }
  60. }
  61. // printf("%d\n",counm);
  62. for(int i=0;i<n;i++){
  63. for(int j=0;j<n;j++){
  64. checkb(i,j);
  65. }
  66. }
  67. //printf("%d\n",counm);
  68. //printf("%d\n",counm);
  69. }
  70.  
Success #stdin #stdout 0s 15552KB
stdin
Standard input is empty
stdout
hello