Submission #1040343

#TimeUsernameProblemLanguageResultExecution timeMemory
1040343nightfalComparing Plants (IOI20_plants)C++14
Compilation error
0 ms0 KiB
#include "plants.h" vector<int> inc,dec; void init(int k, std::vector<int> r) { if(k==2) { inc.resize(n); dec.resize(n); for(int i=0; i<n; i++) {inc[i] = dec[i] = i;} int s; for(s=0; s<n; s++) {if r[i]=0; break;} for(int i=s-1+n; i>=s+1; i--) {if (r[i%n]) inc[i%n] = inc[(i+1)%n];} for(s=0; s<n; s++) {if r[i]=1; break;} for(int i=s-1+n; i>=s+1; i--) {if (r[i%n]==0) dec[i%n] = dec[(i+1)%n];} } return; } int subtask1(int x, int y) { if (x<y) { if (y<= dec[x] or x<= inc[y] and inc[y] <= y) return 1; else if (y <= inc[x] or x<= dec[y] and dec[y] <= y) return -1; } else { if (y<= inc[x] or x<= dec[y] and dec[y] <= y) return 1; else if (y <= dec[x] or x<= inc[y] and inc[y] <= y) return -1; } return 0; } int compare_plants(int x, int y) { if (k==2) return subtask1(x,y); return 0; }

Compilation message (stderr)

plants.cpp:3:1: error: 'vector' does not name a type
    3 | vector<int> inc,dec;
      | ^~~~~~
plants.cpp: In function 'void init(int, std::vector<int>)':
plants.cpp:7:7: error: 'inc' was not declared in this scope; did you mean 'int'?
    7 |       inc.resize(n); dec.resize(n);
      |       ^~~
      |       int
plants.cpp:7:18: error: 'n' was not declared in this scope
    7 |       inc.resize(n); dec.resize(n);
      |                  ^
plants.cpp:7:22: error: 'dec' was not declared in this scope
    7 |       inc.resize(n); dec.resize(n);
      |                      ^~~
plants.cpp:10:30: error: expected '(' before 'r'
   10 |       for(s=0; s<n; s++) {if r[i]=0; break;}
      |                              ^
      |                              (
plants.cpp:12:30: error: expected '(' before 'r'
   12 |       for(s=0; s<n; s++) {if r[i]=1; break;}
      |                              ^
      |                              (
plants.cpp: In function 'int subtask1(int, int)':
plants.cpp:19:15: error: 'dec' was not declared in this scope
   19 |       if (y<= dec[x] or x<= inc[y] and inc[y] <= y) return 1;
      |               ^~~
plants.cpp:19:29: error: 'inc' was not declared in this scope; did you mean 'int'?
   19 |       if (y<= dec[x] or x<= inc[y] and inc[y] <= y) return 1;
      |                             ^~~
      |                             int
plants.cpp:23:14: error: 'inc' was not declared in this scope; did you mean 'int'?
   23 |      if (y<= inc[x] or x<= dec[y] and dec[y] <= y) return 1;
      |              ^~~
      |              int
plants.cpp:23:28: error: 'dec' was not declared in this scope
   23 |      if (y<= inc[x] or x<= dec[y] and dec[y] <= y) return 1;
      |                            ^~~
plants.cpp: In function 'int compare_plants(int, int)':
plants.cpp:29:8: error: 'k' was not declared in this scope
   29 |    if (k==2) return subtask1(x,y);
      |        ^