Compile Error

/in/foo.cc:5:1: error: expected initializer before 'struct'
    5 | struct Node
      | ^~~~~~
/in/foo.cc:8:2: error: 'ant' does not name a type; did you mean 'int'?
    8 | }ant[N],tmp[N];
      |  ^~~
      |  int
/in/foo.cc:9:10: error: 'Node' was not declared in this scope
    9 | bool cmp(Node a, Node b)
      |          ^~~~
/in/foo.cc:9:18: error: 'Node' was not declared in this scope
    9 | bool cmp(Node a, Node b)
      |                  ^~~~
/in/foo.cc:9:24: error: expression list treated as compound expression in initializer [-fpermissive]
    9 | bool cmp(Node a, Node b)
      |                        ^
/in/foo.cc: In function 'int main()':
/in/foo.cc:18:16: error: 'b' was not declared in this scope
   18 |         while(!b[0]) //穷举所有朝向 2^n
      |                ^
/in/foo.cc:22:25: error: 'ant' was not declared in this scope; did you mean 'int'?
   22 |                         ant[i].dir=b[i];
      |                         ^~~
      |                         int
/in/foo.cc:29:49: error: 'ant' was not declared in this scope; did you mean 'int'?
   29 |                         for(int i=1;i<=n;i++)if(ant[i].x>0&&ant[i].x<L){ok=false;break;}
      |                                                 ^~~
      |                                                 int
/in/foo.cc:33:36: error: 'ant' was not declared in this scope; did you mean 'int'?
   33 |                                 if(ant[i].dir==0)ant[i].x--;else ant[i].x++; //0-朝左 1-朝右
      |                                    ^~~
      |                                    int
/in/foo.cc:34:30: error: 'ant' was not declared in this scope; did you mean 'int'?
   34 |                         sort(ant+1,ant+n+1,cmp);
      |                              ^~~
      |                              int
/in/foo.cc:37:33: error: 'tmp' was not declared in this scope; did you mean 'tm'?
   37 |                                 tmp[i].x=ant[i].x; tmp[i].dir=ant[i].dir;
      |                                 ^~~
      |                                 tm
/in/foo.cc:43:41: error: 'tmp' was not declared in this scope; did you mean 'tm'?
   43 |                                         tmp[i].dir=0; tmp[i+1].dir=1;//改变方向
      |                                         ^~~
      |                                         tm
/in/foo.cc:47:42: error: 'tmp' was not declared in this scope; did you mean 'tm'?
   47 |                                 ant[i].x=tmp[i].x; ant[i].dir=tmp[i].dir;
      |                                          ^~~
      |                                          tm

信息

递交者
类型
递交
题目
P2908 蚂蚁爬竹竿
语言
C++
递交时间
2025-05-19 17:31:14
评测时间
2025-05-19 17:31:14
评测机
分数
0
总耗时
0ms
峰值内存
0 Bytes