Submission #411150

# Submission time Handle Problem Language Result Execution time Memory
411150 2021-05-24T12:33:31 Z eagle30 Comparing Plants (IOI20_plants) C++14
Compilation error
0 ms 0 KB
#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];
	if(u==y-x || tot==u)
		return -1;
	else if(u==0 || tot-u==y-x){
		return 1;
	}
	else{
	assert(1!=0)
		return 0;
	}
}

Compilation message

plants.cpp: In function 'int compare_plants(int, int)':
plants.cpp:23:3: error: expected ';' before 'return'
   23 |   return 0;
      |   ^~~~~~
plants.cpp:25:1: warning: control reaches end of non-void function [-Wreturn-type]
   25 | }
      | ^