Submission #421296

#TimeUsernameProblemLanguageResultExecution timeMemory
421296JUANDI321Comparing Plants (IOI20_plants)C++17
Compilation error
0 ms0 KiB
#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; }

Compilation message (stderr)

plants.cpp: In function 'void init(int, std::vector<int>)':
plants.cpp:10:19: error: 'n' was not declared in this scope
   10 |  for(int i = 1; i<n; i++)
      |                   ^