답안 #303107

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
303107 2020-09-19T22:13:54 Z tutis 식물 비교 (IOI20_plants) C++17
5 / 100
117 ms 5880 KB
#include "plants.h"
#include <bits/stdc++.h>
using namespace std;
vector<int>k0, k1;
int K, n;
vector<int>A;
void init(int k, vector<int> r)
{
	K = k;
	n = r.size();
	if (k == 2)
	{
		k0 = k1 = vector<int>(n, 0);
		for (int t = 0; t < 2; t++)
			for (int i = n - 1; i >= 0; i--)
			{
				if (r[i] == 0)
					k0[i] = 1 + k0[(i + 1) % n];
				else
					k1[i] = 1 + k1[(i + 1) % n];
			}
	}
	if (2 * k > n)
	{
		A = vector<int>(n, -1);
		for (int tt = 0; tt < n; tt++)
		{
			for (int i = 0; i < n; i++)
			{
				if (r[i] == 0)
				{
					int j = i;
					for (int t = 0; t < k - 1; t++)
					{
						j--;
						if (j < 0)
							j += n;
						if (r[j] == 0)
							continue;
					}
					A[i] = tt;
					r[i] = n + 100;
					j = i;
					for (int t = 0; t < k - 1; t++)
					{
						j--;
						if (j < 0)
							j += n;
						r[j]--;
					}
				}
			}
		}
	}
}

int compare_plants(int x, int y)
{
	assert(x < y);
	if (K == 2)
	{
		if (k0[x] >= y - x)
			return 1;
		if (k1[x] >= y - x)
			return -1;
		if (k0[y] >= n - y + x)
			return -1;
		if (k1[y] >= n - y + x)
			return 1;
		return 0;
	}
	if (!A.empty())
	{
		if (A[x] < A[y])
			return -1;
		else
			return 1;
	}
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 65 ms 3192 KB Output is correct
7 Correct 81 ms 3448 KB Output is correct
8 Correct 108 ms 5816 KB Output is correct
9 Correct 110 ms 5752 KB Output is correct
10 Correct 108 ms 5752 KB Output is correct
11 Correct 117 ms 5752 KB Output is correct
12 Correct 111 ms 5752 KB Output is correct
13 Correct 105 ms 5752 KB Output is correct
14 Correct 110 ms 5880 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Incorrect 1 ms 256 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 256 KB Output is correct
3 Incorrect 1 ms 256 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Incorrect 0 ms 256 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Incorrect 0 ms 256 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Incorrect 1 ms 256 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 65 ms 3192 KB Output is correct
7 Correct 81 ms 3448 KB Output is correct
8 Correct 108 ms 5816 KB Output is correct
9 Correct 110 ms 5752 KB Output is correct
10 Correct 108 ms 5752 KB Output is correct
11 Correct 117 ms 5752 KB Output is correct
12 Correct 111 ms 5752 KB Output is correct
13 Correct 105 ms 5752 KB Output is correct
14 Correct 110 ms 5880 KB Output is correct
15 Correct 1 ms 256 KB Output is correct
16 Correct 1 ms 256 KB Output is correct
17 Incorrect 1 ms 256 KB Output isn't correct
18 Halted 0 ms 0 KB -