QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#794559#1798. Screamers in the StormI_be_wannaCompile Error//C++203.8kb2024-11-30 14:55:202024-11-30 14:55:26

Judging History

你现在查看的是最新测评结果

  • [2024-11-30 14:55:26]
  • 评测
  • [2024-11-30 14:55:20]
  • 提交

answer

#include<bits/stdc++.h>
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:12:1: error: ‘vector’ does not name a type
   12 | vector<node>sheeps,wolfs;
      | ^~~~~~
answer.code:13:16: error: ‘maxn’ was not declared in this scope
   13 | bool vis_sheep[maxn],vis_wolf[maxn];
      |                ^~~~
answer.code:13:31: error: ‘maxn’ was not declared in this scope
   13 | bool vis_sheep[maxn],vis_wolf[maxn];
      |                               ^~~~
answer.code: In function ‘int main()’:
answer.code:16:7: error: invalid conversion from ‘ssize_t (*)(int, void*, size_t)’ {aka ‘long int (*)(int, void*, long unsigned int)’} to ‘int’ [-fpermissive]
   16 |     t=read;n=read,m=read;
      |       ^~~~
      |       |
      |       ssize_t (*)(int, void*, size_t) {aka long int (*)(int, void*, long unsigned int)}
answer.code:16:14: error: invalid conversion from ‘ssize_t (*)(int, void*, size_t)’ {aka ‘long int (*)(int, void*, long unsigned int)’} to ‘int’ [-fpermissive]
   16 |     t=read;n=read,m=read;
      |              ^~~~
      |              |
      |              ssize_t (*)(int, void*, size_t) {aka long int (*)(int, void*, long unsigned int)}
answer.code:16:21: error: invalid conversion from ‘ssize_t (*)(int, void*, size_t)’ {aka ‘long int (*)(int, void*, long unsigned int)’} to ‘int’ [-fpermissive]
   16 |     t=read;n=read,m=read;
      |                     ^~~~
      |                     |
      |                     ssize_t (*)(int, void*, size_t) {aka long int (*)(int, void*, long unsigned int)}
answer.code:17:9: error: ‘i’ was not declared in this scope
   17 |     rep(i,1,n)
      |         ^
answer.code:17:5: error: ‘rep’ was not declared in this scope
   17 |     rep(i,1,n)
      |     ^~~
answer.code:21:30: error: ‘sheeps’ was not declared in this scope; did you mean ‘sheep’?
   21 |             if(s[i][j]=='S') sheeps.push_back({i,j,0}),s[i][j]='.';
      |                              ^~~~~~
      |                              sheep
answer.code:22:35: error: ‘wolfs’ was not declared in this scope; did you mean ‘wolf’?
   22 |             else if(s[i][j]=='W') wolfs.push_back({i,j,0}),s[i][j]='.';
      |                                   ^~~~~
      |                                   wolf
answer.code:23:19: error: ‘sheeps’ was not declared in this scope; did you mean ‘sheep’?
   23 |     for(int i=0;i<sheeps.size();i++) vis_sheep[i]=1;
      |                   ^~~~~~
      |                   sheep
answer.code:23:38: error: ‘vis_sheep’ was not declared in this scope
   23 |     for(int i=0;i<sheeps.size();i++) vis_sheep[i]=1;
      |                                      ^~~~~~~~~
answer.code:24:19: error: ‘wolfs’ was not declared in this scope; did you mean ‘wolf’?
   24 |     for(int i=0;i<wolfs.size();i++) vis_wolf[i]=1;
      |                   ^~~~~
      |                   wolf
answer.code:24:37: error: ‘vis_wolf’ was not declared in this scope
   24 |     for(int i=0;i<wolfs.size();i++) vis_wolf[i]=1;
      |                                     ^~~~~~~~
answer.code:27:23: error: ‘sheeps’ was not declared in this scope; did you mean ‘sheep’?
   27 |         for(int i=0;i<sheeps.size();i++)//羊的移动
      |                       ^~~~~~
      |                       sheep
answer.code:28:20: error: ‘vis_sheep’ was not declared in this scope
   28 |                 if(vis_sheep[i]){
      |                    ^~~~~~~~~
answer.code:32:48: error: ‘ny’ was not declared in this scope; did you mean ‘nx’?
   32 |                     sheeps[i].x=nx;sheeps[i].y=ny;
      |                                                ^~
      |                                                nx
answer.code:35:23: error: ‘wolfs’ was not declared in this scope; did you mean ‘wolf’?
   35 |         for(int i=0;i<wolfs.size();i++)//狼的移动
      |                       ^~~~~
      |                       wolf
answer.code:36:16: error: ‘vis_wolf’ was not declared in this scope
   36 |             if(vis_wolf[i]){
      |                ^~~~~~~~
answer.code:38:20: error: ‘ny’ was not declared in this scope; did you mean ‘nx’?
   38 |                 if(ny==m+1) ny=1;
      |                    ^~
      |                    nx
answer.code:39:42: error: ‘ny’ was not declared in this scope; did you mean ‘nx’?
   39 |                 wolfs[i].x=nx;wolfs[i].y=ny;
      |                                          ^~
      |                                          nx
answer.code:46:31: error: ‘sheeps’ was not declared in this scope; did you mean ‘sheep’?
   46 |                 for(int k=0;k<sheeps.size();k++)
      |                               ^~~~~~
      |                               sheep
answer.code:47:24: error: ‘vis_sheep’ was not declared in this scope
   47 |                     if(vis_sheep[k]&&i==sheeps[k].x&&j==sheeps[k].y) flag_sheep=k;
      |                        ^~~~~~~~~
answer.code:48:31: error: ‘wolfs’ was not declared in this scope; did you mean ‘wolf’?
   48 |                 for(int k=0;k<wolfs.size();k++)
      |                               ^~~~~
      |  ...