Submission #411143

#TimeUsernameProblemLanguageResultExecution timeMemory
411143eagle30Comparing Plants (IOI20_plants)C++17
Compilation error
0 ms0 KiB
#include "plants.h" #include<bits/stdc++.h> using namespace std; int pref[1000000], n, tot=0; void init(int k, vector<int> r) { n=r.size(); for(int i=0; i<n; i++){ tot+=r[i]; pref[i+1]=pref[i]+r[i]; } return; } int compare_plants(int x, int y) { int u=pref[y]-pref[x]; assert(1) if(u==y-x) return -1; else if(u==0){ return 1; } else{ assert(1); return 0; } }

Compilation message (stderr)

plants.cpp: In function 'int compare_plants(int, int)':
plants.cpp:17:2: error: expected ';' before 'if'
   17 |  if(u==y-x)
      |  ^~
plants.cpp:19:2: error: 'else' without a previous 'if'
   19 |  else if(u==0){
      |  ^~~~