Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- typedef long long int ll;
- typedef unsigned long long int ull;
- typedef vector<int> vi;
- typedef vector<vi> vvi;
- typedef pair<int,int> pii;
- typedef vector< pii > vpii;
- typedef set<int> sti;
- #define pb push_back
- #define pob pop_back
- #define mp make_pair
- #define ff first
- #define ss second
- #define loop1(i,n) for(int i=1; i<=int(n); i++)
- #define loop(i,y) for(int i=0; i<int(y); i++)
- #define rloop(i,y) for(int i=int(y)-1; i>=0; i--)
- #define read() freopen("input.txt", "r", stdin)
- #define write() freopen("output.txt", "w", stdout)
- #define cspf(i) printf("Case %d:\n", i)
- /// Constants
- #define eps 1e-9
- #define PI acos(-1.0) // 3.1415926535897932
- int main()
- {
- read();
- int n;
- while(1){
- scanf("%d",&n);
- if(n==0)
- break;
- char a[110][110];
- loop(i,n){
- scanf("%s",a[i]);
- }
- int cnt=0,check[110][110];
- loop(i,n){
- loop(j,n){
- check[i][j]=0;
- }
- }
- loop(i,n){
- loop(j,n){
- if(a[i][j]=='X' || check[i][j]==1)
- continue;
- int r=0,c=0;
- for(int k=0;k<j;k++){
- if(check[i][k]!=0)
- r=1;
- if(r==1 && a[i][k]=='X')
- r=0;
- }
- for(int k=0;k<i;k++){
- if(check[k][j]!=0)
- c=1;
- if(c==1 && a[k][j]=='X')
- c=0;
- }
- if(r==0 && c==0){
- cnt++;
- if(a[i+1][j+1]=='X' && a[i][j+1]=='.')
- check[i][j+1]=1;
- else
- check[i][j]=1;
- }
- }
- }
- loop(i,n){
- loop(j,n){
- // printf("%d ",check[i][j]);
- }
- //printf("\n");
- }
- printf("%d\n",cnt);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement