0分求助
  • 板块P1191 矩形
  • 楼主654179_qwq
  • 当前回复2
  • 已保存回复2
  • 发布时间2022/5/19 13:38
  • 上次更新2023/10/28 01:08:12
查看原帖
0分求助
654179
654179_qwq楼主2022/5/19 13:38

8 WA , 2 TLE8\ \color{red}WA\color{black}\ ,\ 2\ \color{darkblue}TLE

#include<bits/stdc++.h>
using namespace std;
inline long long rd(){//quick read
	long long x=0;bool ntv=false;char c=getchar();
	while((c<'0'||c>'9')&&c!='-')c=getchar();
	if(c=='-')ntv=true;else x=(c^48);c=getchar();
	while(c>='0'&&c<='9'){x=x*10+(c^48);c=getchar();}
	return ntv?-x:x;
}
int main(){
    //read
	long long n=rd(),m,count=0;
	char w[n][n];
	for(int i=0;i<n;getchar()+i++)
	    for(int j=0;j<n;j++)
	        w[i][j]=getchar();
	        
	//count
	for(int i=0;i<n;i++)
	 for(int j=0;j<n;j++)
	  if(w[i][j]=='W')
	   for(int ii=0;ii<=i;ii++)
	    for(int jj=0;jj<=j;jj++)
         if(w[ii][jj]=='W'){
    		m=1;
    		for(int k=ii;k<=i&&m==1;k++)
    		  for(int l=jj;l<=j&&m==1;l++)
        	    if(w[k][l]=='B')
        	      m=0;
    		if(m==1)
    		  count++;
    	 }
    	 
    //print
	cout<<count;
	return 0;
}
2022/5/19 13:38
加载中...