답안 #301168

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
301168 2020-09-17T17:10:30 Z luciocf 식물 비교 (IOI20_plants) C++14
0 / 100
81 ms 3192 KB
#include <bits/stdc++.h>
#include "plants.h"

using namespace std;

const int maxn = 2e5+10;

int n;
int head[maxn];

int r[maxn];

void init(int k, vector<int> a)
{
	n = a.size();
	for (int i = 0; i < n; i++)
		r[i] = a[i];

	head[0] = head[1] = 0;
	int at = r[0];

	for (int i = 1; i < n-1; i++)
	{
		if (r[i] == at) head[i+1] = head[i];
		else
		{
			head[i+1] = i;
			at = r[i];
		}
	}
}

int compare_plants(int x, int y)
{
	if (x == 0 && y == n-1)
	{
		if (r[n-1] == 0) return -1;
		return 1;
	}

	if (x == n-1 && y == 0)
	{
		if (r[n-1] == 0) return 1;
		return -1;
	}

	if (x < y && head[y] <= x)
	{
		if (r[x] == 0) return 1;
		return -1;
	}
	else if (x > y && head[x] <= y)
	{
		if (r[y] == 0) return -1;
		return 1;
	}
	else if (head[x] == 0 && head[n-1] <= y)
	{
		if (r[y] == 0 && r[n-1] == 0 && r[0] == 0) return -1;
		if (r[y] == 1 && r[n-1] == 1 && r[0] == 1) return 1;
	}
	else if (head[y] == 0 && head[n-1] <= x)
	{
		if (r[x] == 0 && r[n-1] == 0 && r[0] == 0) return 1;
		if (r[x] == 1 && r[n-1] == 1 && r[0] == 1) return -1;
	}
	return 0;
}
# 결과 실행 시간 메모리 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 Correct 0 ms 256 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Incorrect 81 ms 3192 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 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 384 KB Output is correct
2 Correct 1 ms 384 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 1 ms 384 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 384 KB Output is correct
3 Correct 1 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 0 ms 256 KB Output is correct
2 Correct 0 ms 384 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 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 1 ms 384 KB Output is correct
6 Incorrect 81 ms 3192 KB Output isn't correct
7 Halted 0 ms 0 KB -