답안 #792123

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
792123 2023-07-24T15:31:18 Z mousebeaver 식물 비교 (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, -1); //-1 = not already known

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

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

	//vector<int> test = height;
	//int temp = 0;
}

int compare_plants(int x, int y) 
{
	if(height[x] > height[y])
	{
		return 1;
	}
	return -1;
}

Compilation message

plants.cpp: In function 'void init(int, std::vector<int>)':
plants.cpp:23:34: warning: unused variable 'a' [-Wunused-variable]
   23 |   while(candidates.empty()){ int a = 0;}
      |                                  ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Runtime error 1 ms 340 KB Execution killed with signal 11
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 Runtime error 1 ms 340 KB Execution killed with signal 11
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 Runtime error 1 ms 340 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 340 KB Execution killed with signal 11
2 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 Runtime error 1 ms 340 KB Execution killed with signal 11
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 Runtime error 1 ms 340 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Runtime error 1 ms 340 KB Execution killed with signal 11
5 Halted 0 ms 0 KB -