Submission #429414

#TimeUsernameProblemLanguageResultExecution timeMemory
429414JUANDI321Comparing Plants (IOI20_plants)C++17
Compilation error
0 ms0 KiB
#include "plants.h"
#include <vector>
#include <iostream>

using namespace std;
int l[200100];
int n;
void init(int k, vector<int> r) 
{
	int nn = r.size();
	n = nn;
	l[0] = 200100;
	for(int i = 0; i<n; i++)
	{
		if(r[i] == 1)l[i+1] = l[i] + 1;
		else l[i+1] = l[i] - 1;
	}
	return;
}

int compare_plants(int x, int y) 
{
	if( y-x == l[y]-l[x])return -1;
	if( y-x == -1 *(l[y]-l[x]))return 1;
	if( n-y + x == l[n]-l[y] + l[x] - l[0])return 1;
	if( n-y + x == -1*(l[n]-l[y] + l[x] - l[0]))return -1;
	return 0;
}

int main()
{
	vector<int> list = {0, 1, 1};
	init(2, list);
	cout<<compare_plants(0, 1)<<endl;
	cout<<compare_plants(0, 2)<<endl;
}

Compilation message (stderr)

/usr/bin/ld: /tmp/cceMz85L.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccZHQCDL.o:plants.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status