Advertisement
erfanul007

UVa 639

Jan 9th, 2019
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.27 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. typedef long long int ll;
  5. typedef unsigned long long int ull;
  6. typedef vector<int> vi;
  7. typedef vector<vi> vvi;
  8. typedef pair<int,int> pii;
  9. typedef vector< pii > vpii;
  10. typedef set<int> sti;
  11.  
  12. #define pb push_back
  13. #define pob pop_back
  14. #define mp make_pair
  15. #define ff first
  16. #define ss second
  17. #define loop1(i,n) for(int i=1; i<=int(n); i++)
  18. #define loop(i,y) for(int i=0; i<int(y); i++)
  19. #define rloop(i,y) for(int i=int(y)-1; i>=0; i--)
  20. #define read() freopen("input.txt", "r", stdin)
  21. #define write() freopen("output.txt", "w", stdout)
  22. #define cspf(i) printf("Case %d:\n", i)
  23. /// Constants
  24. #define eps 1e-9
  25. #define PI acos(-1.0) // 3.1415926535897932
  26.  
  27. int main()
  28. {
  29. read();
  30. int n;
  31. while(1){
  32. scanf("%d",&n);
  33. if(n==0)
  34. break;
  35. char a[110][110];
  36. loop(i,n){
  37. scanf("%s",a[i]);
  38. }
  39. int cnt=0,check[110][110];
  40. loop(i,n){
  41. loop(j,n){
  42. check[i][j]=0;
  43. }
  44. }
  45. loop(i,n){
  46. loop(j,n){
  47. if(a[i][j]=='X' || check[i][j]==1)
  48. continue;
  49. int r=0,c=0;
  50. for(int k=0;k<j;k++){
  51. if(check[i][k]!=0)
  52. r=1;
  53. if(r==1 && a[i][k]=='X')
  54. r=0;
  55. }
  56. for(int k=0;k<i;k++){
  57. if(check[k][j]!=0)
  58. c=1;
  59. if(c==1 && a[k][j]=='X')
  60. c=0;
  61. }
  62. if(r==0 && c==0){
  63. cnt++;
  64. if(a[i+1][j+1]=='X' && a[i][j+1]=='.')
  65. check[i][j+1]=1;
  66. else
  67. check[i][j]=1;
  68. }
  69. }
  70. }
  71. loop(i,n){
  72. loop(j,n){
  73. // printf("%d ",check[i][j]);
  74. }
  75. //printf("\n");
  76. }
  77. printf("%d\n",cnt);
  78. }
  79. return 0;
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement