답안 #386050

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
386050 2021-04-05T14:00:07 Z AdOjis485 식물 비교 (IOI20_plants) C++17
0 / 100
1 ms 512 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, -1);
	
	int i = 0;
	while(i < n && range[i] < 0)
	{
		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;
		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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Incorrect 1 ms 364 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Incorrect 1 ms 364 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Incorrect 1 ms 364 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 512 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Incorrect 1 ms 364 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Incorrect 1 ms 364 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Incorrect 1 ms 364 KB Output isn't correct
4 Halted 0 ms 0 KB -