AC

root  •  1年前


#include <bits/stdc++.h>
#include <math.h>
using namespace std; 
int qw[1001],qw1[1001];
int dx[4]={0,0,1,-1};
int dy[4]={1,-1,0,0}; 
int shu[101][101];
int x,y;
void show(int a,int b){
shu[a][b]=0;
int tx,ty;

int front=0,rear=1; int head,u; qw[1]=a; qw1[1]=b;

while(front<rear){
	head=qw[++front];
	u=qw1[front];
	for(int i=0;i<4;i++){
		tx=head+dx[i];
		ty=u+dy[i];
		if(tx>0&&tx<=x&&ty>0&&ty<=y&&shu[tx][ty]==1){
			qw[++rear]=tx;
			qw1[rear]=ty;
			shu[tx][ty]=0;
		}
	}
}
}
int main(){
cin>>x>>y;
char ch;
for(int i=1;i<=x;i++)
 for(int j=1;j<=y;j++){
 	cin>>ch;
 	if(ch=='0'){
 		shu[i][j]=0;
	 }
	 else shu[i][j]=1;
 }
 int top=0;
 for(int i=1;i<=x;i++)
 for(int j=1;j<=y;j++){
 	if(shu[i][j]==1){
     top++;
     show(i,j);
	 }
 }
 cout<<top<<endl;
return 0;
}

评论:

include<bits/stdc++.h>

using namespace std; int f[62505]; int main() {

int w=0,l=0;
char s;
for(int i=1;;i++) 
{
	cin>>s;
	if(s=='E') break;
    else if(s=='W') f[i]=1; 
    else f[i]=2;
}
for(int i=1;;i++)
{
    if(f[i]==1) w++;
    if(f[i]==2) l++;
    if(f[i]==0)
    {
        cout<<w<<":"<<l<<endl<<endl;
        break;
    }
    if(w-l>=2 || l-w>=2)
        if(w>=11 || l>=11) 
        {
            cout<<w<<":"<<l<<endl;
            w=0;
            l=0;
        }
}
w=0;l=0;
for(int i=1;;i++) 
{
    if(f[i]==1)w++;
    if(f[i]==2)l++;
    if(f[i]==0)
    {
        cout<<w<<":"<<l;
        break;
    }
    if(w-l>=2 || l-w>=2)
        if(w>=21 || l>=21)
        {
            cout<<w<<":"<<l<<endl;
            w=0;
            l=0;
        }
}
return 0;

}


刘宸志 CEUA  •  1年前

include <stdio.h>

include <string.h>

int main() {

char c[5][100];
int a[5];
int m = 0;
for (int i = 0; i < 5; i++) {
	scanf("%s", c[i]);
	a[i] = strlen(c[i]);
}
for (int i = 0; i < 5; i++) {
	if (a[i] > a[m]) {
		m = i;
	}
}
printf("%s", c[m]);
return 0;

}


刘谦  •  1年前

请先登录,才能进行评论