Submission #377580

#TimeUsernameProblemLanguageResultExecution timeMemory
377580marat0210Comparing Plants (IOI20_plants)C++14
Compilation error
0 ms0 KiB
#include <plants.h> #include <bits/stdc++.h> using namespace std; vector <int> s; int n; void init(int k, vector <int> r) { n = r.size(); s.push_back(0); for (int i: r) { s.push_back(s.back() + i); } } int compare_plants(int x, y) { if (x > y) return -compare_plants(y, x); if (s[x] == s[y]) return 1; if (s[y] == s[n] and s[0] == s[x]) return -1; if (s[x] - x == s[y] - y) return -1; if (s[y] - y == s[n] - n and s[0] == s[x] - x) return 1; return 0; }

Compilation message (stderr)

plants.cpp:18:27: error: 'y' has not been declared
   18 | int compare_plants(int x, y)
      |                           ^
plants.cpp: In function 'int compare_plants(int, int)':
plants.cpp:20:13: error: 'y' was not declared in this scope
   20 |     if (x > y) return -compare_plants(y, x);
      |             ^
plants.cpp:21:19: error: 'y' was not declared in this scope
   21 |     if (s[x] == s[y]) return 1;
      |                   ^
plants.cpp:22:11: error: 'y' was not declared in this scope
   22 |     if (s[y] == s[n] and s[0] == s[x]) return -1;
      |           ^
plants.cpp:23:23: error: 'y' was not declared in this scope
   23 |     if (s[x] - x == s[y] - y) return -1;
      |                       ^
plants.cpp:24:11: error: 'y' was not declared in this scope
   24 |     if (s[y] - y == s[n] - n and s[0] == s[x] - x) return 1;
      |           ^