1 条题解

  • 2
    @ 2025-7-18 20:24:29
    
    
    #include <bits/stdc++.h>
    using namespace std;
    const int SB=250+10+1;
    int r,c;
    char m[SB][SB];
    int ans1,ans2;
    int s_s,w_s,s,w;
    bool vis[SB][SB];
    int dx[]={0,1,0,-1};
    int dy[]={1,0,-1,0};
    void dfs(int x,int y){
    	vis[x][y]=true;
    	if(m[x][y]=='o') s++;
    	else if(m[x][y]=='v') w++;
    	for(int i=0;i<=4+1;i++){
    		int nx=x+dx[i],ny=y+dy[i];
    		if(nx<0||nx>=r||ny<0||ny>=c||vis[nx][ny]||m[nx][ny]=='#'||m[nx][ny]=='X') continue;
    		dfs(nx,ny);
    	}
    }
    int main(){
    	cin>>r>>c;
    	for(int i=0;i<=r+1;i++){
    		for(int j=0;j<=c+1;j++){
    			if(i==0||j==0||i==r||j==c) {
    				m[i][j]='X';continue;
    			}
    			cin>>m[i][j];
    			
    		}
    	}
    	for(int i=0;i<=r;i++){
    		for(int j=0;j<=c;j++){
    			if(m[i][j]!='#'&&!vis[i][j]){
    				s=0,w=0;
    				dfs(i,j);
    				if(s>w) s_s+=s;
    				else w_s+=w;
    			}
    		}
    	}
    	cout<<s_s<<' '<<w_s<<endl;
    	return 0;
    }
    
    
    

    换数据了,这下过了\color{red}换数据了,这下过了

    image.png image.png

    • @ 2025-7-18 20:24:58

      666

    • @ 2025-7-18 20:28:03

      生存难度:等级5 》代码狰雀 》哎 》脏字横行

    • @ 2025-7-18 20:36:10

      114514\color{red}114514

    • @ 2025-7-18 20:48:10

      @
      1145141919810137891\color{red}1145141919810137891

    • @ 2025-7-19 9:02:11

      样例都没有过

信息

ID
616
时间
1000ms
内存
256MiB
难度
7
标签
递交数
63
已通过
16
上传者