Submission #792086

# Submission time Handle Problem Language Result Execution time Memory
792086 2023-07-24T14:57:23 Z mousebeaver Comparing Plants (IOI20_plants) C++14
0 / 100
1 ms 340 KB
#include "plants.h"
#include <bits/stdc++.h>
using namespace std;

vector<int> height(0);

void init(int k, vector<int> r) 
{
	int n = r.size();
	height.assign(n, -2); //-2 = No info, -1 = already candidate
	vector<int> candidates(0);
	int val = k;
	int counter = n;

	do
	{
		for(int i = 0; i < n; i++)
		{
			if(height[i] == -2 && r[i] == val)
			{
				candidates.push_back(i);
				height[i] = -1;
			}
		}	
		if(candidates.empty())
		{
			val--;
		}
	}while(candidates.empty());
	sort(candidates.begin(), candidates.end());

	int index = 0;
	while((candidates[index]+k-1)%n >= candidates[(index+1)%candidates.size()])
	{
		index++;
	}
	height[candidates[index]] = counter;
	counter--;
	candidates.erase(candidates.begin()+index);

	return;
}

int compare_plants(int x, int y) 
{
	if(height[x] > height[y])
	{
		return 1;
	}
	return -1;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -