Submission #386048

# Submission time Handle Problem Language Result Execution time Memory
386048 2021-04-05T13:57:36 Z AdOjis485 Comparing Plants (IOI20_plants) C++17
0 / 100
4000 ms 256 KB
#include "plants.h"
#include <vector>
using namespace std;

vector<int> range;

void init(int k, vector<int> r) 
{
	int n = r.size();
	range.resize(n);
	
	int i = 0;
	while(i < n)
	{
		int cur = i;
		while(i < n && r[i] > 0) i ++;
		if(i == n)
		{
			i = 0;
			while(r[i] > 0) i ++;
		}
		for(int j = cur; j != i; j = (j + 1) % n) range[j] = i;
	}
	return;
}

int compare_plants(int x, int y) 
{
	int fac = 1;
	if(x > y)
	{
		swap(x, y);
		fac = -1;
	}	
	int ans = 0;
	if(range[x] > y || range[x] < x) ans = -1;
	else if(range[y] > x) ans = 1;
	return fac * ans;
}
# Verdict Execution time Memory Grader output
1 Execution timed out 4070 ms 256 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4027 ms 256 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4027 ms 256 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4030 ms 256 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4089 ms 256 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4049 ms 256 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4070 ms 256 KB Time limit exceeded
2 Halted 0 ms 0 KB -