QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#794556 | #1798. Screamers in the Storm | I_be_wanna | Compile Error | / | / | C++20 | 3.7kb | 2024-11-30 14:54:25 | 2024-11-30 14:54:31 |
Judging History
answer
int n,m,t;
char s[110][110];
int c[110][110];
int sheep[110][110],wolf[110][110];
struct node{
int x,y,val;///val表示有几回合没有吃到东西了
};
vector<node>sheeps,wolfs;
bool vis_sheep[maxn],vis_wolf[maxn];
int main(){
t=read;n=read,m=read;
rep(i,1,n)
cin>>s[i]+1;
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++)
if(s[i][j]=='S') sheeps.push_back({i,j,0}),s[i][j]='.';
else if(s[i][j]=='W') wolfs.push_back({i,j,0}),s[i][j]='.';
for(int i=0;i<sheeps.size();i++) vis_sheep[i]=1;
for(int i=0;i<wolfs.size();i++) vis_wolf[i]=1;
//cout<<sheeps.size()<<" "<<wolfs.size()<<endl;
while(t--){
for(int i=0;i<sheeps.size();i++)//羊的移动
if(vis_sheep[i]){
//这个羊还活着
int nx=sheeps[i].x+1,ny=sheeps[i].y;
if(nx==n+1) nx=1;
sheeps[i].x=nx;sheeps[i].y=ny;
//cout<<i<<" "<<nx<<" "<<ny<<endl;
}
for(int i=0;i<wolfs.size();i++)//狼的移动
if(vis_wolf[i]){
int nx=wolfs[i].x,ny=wolfs[i].y+1;
if(ny==m+1) ny=1;
wolfs[i].x=nx;wolfs[i].y=ny;
// cout<<i<<" "<<nx<<" "<<ny<<endl;
}
// puts("+++++++++++++++++");
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++){
int flag_sheep=-1,flag_wolf=-1;
for(int k=0;k<sheeps.size();k++)
if(vis_sheep[k]&&i==sheeps[k].x&&j==sheeps[k].y) flag_sheep=k;
for(int k=0;k<wolfs.size();k++)
if(vis_wolf[k]&&i==wolfs[k].x&&j==wolfs[k].y) flag_wolf=k;
if(flag_wolf!=-1&&flag_sheep!=-1){
//狼吃羊
vis_sheep[flag_sheep]=0;//羊死了
s[i][j]='*';//草地变成尸体
wolfs[flag_wolf].val=0;
}
else if(flag_wolf!=-1&&flag_sheep==-1){
wolfs[flag_wolf].val++;
if(wolfs[flag_wolf].val==10){
vis_wolf[flag_wolf]=0;
s[i][j]='*';
}
}
else if(flag_wolf==-1&&flag_sheep!=-1){
if(s[i][j]=='#'){
s[i][j]='.';c[i][j]=-1;//羊吃草
sheeps[flag_sheep].val=0;
}
else{
sheeps[flag_sheep].val++;
if(sheeps[flag_sheep].val==5){
vis_sheep[flag_sheep]=0;
s[i][j]='*';
}
}
}
}
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++){
c[i][j]=min(3,c[i][j]+1);
if(c[i][j]==3){
if(s[i][j]!='*') s[i][j]='#';//这个地方长草
}
}
// for(int i=1;i<=3;i++) cout<<s[i][1]<<" "<<c[i][1]<<endl;
// puts("++++++++++++++");
}
for(int i=0;i<sheeps.size();i++)
if(vis_sheep[i]){
int x=sheeps[i].x,y=sheeps[i].y;
// cout<<i<<" "<<x<<" "<<y<<endl;
s[x][y]='S';
}
for(int i=0;i<wolfs.size();i++)
if(vis_wolf[i]){
int x=wolfs[i].x,y=wolfs[i].y;
s[x][y]='W';
//cout<<i<<" "<<x<<" "<<y<<endl;
}
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++)
if(c[i][j]==3){
if(s[i][j]=='.') s[i][j]='#';
}
for(int i=1;i<=n;i++){
cout<<(s[i]+1)<<endl;
}
return 0;
}
详细
answer.code:11:1: error: ‘vector’ does not name a type 11 | vector<node>sheeps,wolfs; | ^~~~~~ answer.code:12:16: error: ‘maxn’ was not declared in this scope 12 | bool vis_sheep[maxn],vis_wolf[maxn]; | ^~~~ answer.code:12:31: error: ‘maxn’ was not declared in this scope 12 | bool vis_sheep[maxn],vis_wolf[maxn]; | ^~~~ answer.code: In function ‘int main()’: answer.code:15:7: error: ‘read’ was not declared in this scope 15 | t=read;n=read,m=read; | ^~~~ answer.code:16:9: error: ‘i’ was not declared in this scope 16 | rep(i,1,n) | ^ answer.code:16:5: error: ‘rep’ was not declared in this scope 16 | rep(i,1,n) | ^~~ answer.code:20:30: error: ‘sheeps’ was not declared in this scope; did you mean ‘sheep’? 20 | if(s[i][j]=='S') sheeps.push_back({i,j,0}),s[i][j]='.'; | ^~~~~~ | sheep answer.code:21:35: error: ‘wolfs’ was not declared in this scope; did you mean ‘wolf’? 21 | else if(s[i][j]=='W') wolfs.push_back({i,j,0}),s[i][j]='.'; | ^~~~~ | wolf answer.code:22:19: error: ‘sheeps’ was not declared in this scope; did you mean ‘sheep’? 22 | for(int i=0;i<sheeps.size();i++) vis_sheep[i]=1; | ^~~~~~ | sheep answer.code:22:38: error: ‘vis_sheep’ was not declared in this scope 22 | for(int i=0;i<sheeps.size();i++) vis_sheep[i]=1; | ^~~~~~~~~ answer.code:23:19: error: ‘wolfs’ was not declared in this scope; did you mean ‘wolf’? 23 | for(int i=0;i<wolfs.size();i++) vis_wolf[i]=1; | ^~~~~ | wolf answer.code:23:37: error: ‘vis_wolf’ was not declared in this scope 23 | for(int i=0;i<wolfs.size();i++) vis_wolf[i]=1; | ^~~~~~~~ answer.code:26:23: error: ‘sheeps’ was not declared in this scope; did you mean ‘sheep’? 26 | for(int i=0;i<sheeps.size();i++)//羊的移动 | ^~~~~~ | sheep answer.code:27:20: error: ‘vis_sheep’ was not declared in this scope 27 | if(vis_sheep[i]){ | ^~~~~~~~~ answer.code:31:48: error: ‘ny’ was not declared in this scope; did you mean ‘nx’? 31 | sheeps[i].x=nx;sheeps[i].y=ny; | ^~ | nx answer.code:34:23: error: ‘wolfs’ was not declared in this scope; did you mean ‘wolf’? 34 | for(int i=0;i<wolfs.size();i++)//狼的移动 | ^~~~~ | wolf answer.code:35:16: error: ‘vis_wolf’ was not declared in this scope 35 | if(vis_wolf[i]){ | ^~~~~~~~ answer.code:37:20: error: ‘ny’ was not declared in this scope; did you mean ‘nx’? 37 | if(ny==m+1) ny=1; | ^~ | nx answer.code:38:42: error: ‘ny’ was not declared in this scope; did you mean ‘nx’? 38 | wolfs[i].x=nx;wolfs[i].y=ny; | ^~ | nx answer.code:45:31: error: ‘sheeps’ was not declared in this scope; did you mean ‘sheep’? 45 | for(int k=0;k<sheeps.size();k++) | ^~~~~~ | sheep answer.code:46:24: error: ‘vis_sheep’ was not declared in this scope 46 | if(vis_sheep[k]&&i==sheeps[k].x&&j==sheeps[k].y) flag_sheep=k; | ^~~~~~~~~ answer.code:47:31: error: ‘wolfs’ was not declared in this scope; did you mean ‘wolf’? 47 | for(int k=0;k<wolfs.size();k++) | ^~~~~ | wolf answer.code:48:24: error: ‘vis_wolf’ was not declared in this scope 48 | if(vis_wolf[k]&&i==wolfs[k].x&&j==wolfs[k].y) flag_wolf=k; | ^~~~~~~~ answer.code:51:21: error: ‘vis_sheep’ was not declared in this scope 51 | vis_sheep[flag_sheep]=0;//羊死了 | ^~~~~~~~~ answer.code:53:21: error: ‘wolfs’ was not declared in this scope; did you mean ‘wolf’? 53 | wolfs[flag_wolf].val=0; | ^~~~~ | wolf answer.code:56:21: error: ‘wolfs’ was not declared in this scope; did you mean ‘wolf’? 56 | wolfs[flag_wolf].val++; | ^~~~~ | wolf answer.code:58:25: error: ‘vis_wolf’ was not declared in this scope 58 | vis_wolf[flag_w...