# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
421296 | 2021-06-09T01:37:14 Z | JUANDI321 | Comparing Plants (IOI20_plants) | C++17 | 0 ms | 0 KB |
#include "plants.h" #include <vector> #include <iostream> using namespace std; int sumpf[200010]; void init(int k, vector<int> r) { sumpf[0] = 200010; for(int i = 1; i<n; i++) { sumpf[i]=sumpf[i-1]+r[i]; if(r[i]==0)sumpf[i]--; } return; } int compare_plants(int x, int y) { int dis = y-x+1; if(sumpf[y]-sumpf[x-1] == dis)return 1; if(sumpf[y]-sumpf[x-1] == -1*dis)return -1; return 0; }