답안 #792100

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
792100 2023-07-24T15:13:46 Z mousebeaver 식물 비교 (IOI20_plants) C++14
0 / 100
56 ms 4796 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, -1); //-1 = already known
	int counter = n;

	for(int nodes = 0; nodes < n; nodes++)
	{
		int val = 0;
		for(int i = 0; i < n; i++)
		{
			if(height[i] == -1)
			{
				val = max(val, r[i]);
			}
		}
		vector<int> candidates(0);
		for(int i = 0; i < n; i++)
		{
			if(height[i] == -1 && r[i] == val)
			{
				candidates.push_back(i);
			}
		}
		sort(candidates.begin(), candidates.end());

		int index = 0;
		while(index < (int) candidates.size()-1 && (candidates[index]+k-1) >= candidates[(index+1)])
		{
			index++;
		}
		height[candidates[index]] = counter;
		counter--;
		for(int i = 0; i < k; i++)
		{
			r[(candidates[index]+i)%n]++;
		}
		candidates.clear();
	}

	//vector<int> test = height;
	//int temp = 0;
	for(int i = 0; i < n; i++)
	{
		height[i] = n-height[i];
	}
}

int compare_plants(int x, int y) 
{
	if(height[x] > height[y])
	{
		return 1;
	}
	return -1;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Incorrect 0 ms 300 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Incorrect 1 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Incorrect 1 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Incorrect 56 ms 4796 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 300 KB Output is correct
3 Incorrect 1 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Incorrect 0 ms 304 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Incorrect 0 ms 300 KB Output isn't correct
4 Halted 0 ms 0 KB -