Submission #496690

# Submission time Handle Problem Language Result Execution time Memory
496690 2021-12-21T21:32:32 Z Hanksburger Comparing Plants (IOI20_plants) C++17
19 / 100
217 ms 5828 KB
#include "plants.h"
#include <bits/stdc++.h>
using namespace std;
int S[200005], T[200005], N, K;
bool subtask1, subtask2;
vector<int> R;
void init(int k, vector<int> r)
{
	N=r.size();
	K=k;
	R=r;
	if (K==2)
	{
		subtask1=1;
		for (int i=0; i<N; i++)
		{
			for (int j=i+1; j<N; j++)
			{
				if (R[i]!=R[j])
				{
					for (int l=i; l<j; l++)
						S[l]=j;
					i=j-1;
					break;
				}
			}
			if (S[i]==0)
			{
				for (int j=0; j<i; j++)
				{
					if (R[i]!=R[j])
					{
						for (int l=i; l<N; l++)
							S[l]=j;
						i=N-1;
						break;
					}
				}
			}
		}
	}
	else if (N<=5000 && 2*K>N)
	{
		subtask2=1;
		for (int i=1; i<=N; i++)
		{
			int cnt=0;
			for (int j=N-K+1; j<N; j++)
			{
				if (R[j] || T[j])
					cnt++;
				else
					cnt=0;
			}
			for (int j=0; j<N; j++)
			{
				if (R[j] || T[j])
				{
					cnt++;
					continue;
				}
				if (cnt>=K-1)
				{
					T[j]=i;
					for (int l=(j-K+1+N)%N; l!=j; l=(l+1)%N)
						R[l]--;
					break;
				}
				cnt=0;
			}
		}
	}
}
int compare_plants(int x, int y)
{
	if (subtask1)
	{
		if (S[x]>=y || S[x]<x)
		{
			if (R[x])
				return -1;
			else
				return 1;
		}
		else if (S[y]>=x && S[y]<y)
		{
			if (R[y])
				return 1;
			else
				return -1;
		}
		return 0;
	}
	else if (subtask2)
	{
		if (T[x]<T[y])
			return 1;
		else
			return -1;
	}
}

Compilation message

plants.cpp: In function 'int compare_plants(int, int)':
plants.cpp:101:1: warning: control reaches end of non-void function [-Wreturn-type]
  101 | }
      | ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 47 ms 3036 KB Output is correct
7 Correct 51 ms 3396 KB Output is correct
8 Correct 67 ms 5708 KB Output is correct
9 Correct 65 ms 5732 KB Output is correct
10 Correct 77 ms 5828 KB Output is correct
11 Correct 67 ms 5700 KB Output is correct
12 Correct 64 ms 5748 KB Output is correct
13 Correct 62 ms 5744 KB Output is correct
14 Correct 81 ms 5748 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 300 KB Output is correct
5 Correct 1 ms 308 KB Output is correct
6 Correct 7 ms 312 KB Output is correct
7 Correct 184 ms 5008 KB Output is correct
8 Correct 3 ms 312 KB Output is correct
9 Correct 7 ms 304 KB Output is correct
10 Correct 191 ms 5208 KB Output is correct
11 Correct 136 ms 4964 KB Output is correct
12 Correct 145 ms 5128 KB Output is correct
13 Correct 217 ms 5012 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 300 KB Output is correct
5 Correct 1 ms 308 KB Output is correct
6 Correct 7 ms 312 KB Output is correct
7 Correct 184 ms 5008 KB Output is correct
8 Correct 3 ms 312 KB Output is correct
9 Correct 7 ms 304 KB Output is correct
10 Correct 191 ms 5208 KB Output is correct
11 Correct 136 ms 4964 KB Output is correct
12 Correct 145 ms 5128 KB Output is correct
13 Correct 217 ms 5012 KB Output is correct
14 Incorrect 52 ms 5620 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Incorrect 45 ms 3176 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Incorrect 0 ms 204 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Incorrect 0 ms 204 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 47 ms 3036 KB Output is correct
7 Correct 51 ms 3396 KB Output is correct
8 Correct 67 ms 5708 KB Output is correct
9 Correct 65 ms 5732 KB Output is correct
10 Correct 77 ms 5828 KB Output is correct
11 Correct 67 ms 5700 KB Output is correct
12 Correct 64 ms 5748 KB Output is correct
13 Correct 62 ms 5744 KB Output is correct
14 Correct 81 ms 5748 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 0 ms 300 KB Output is correct
19 Correct 1 ms 308 KB Output is correct
20 Correct 7 ms 312 KB Output is correct
21 Correct 184 ms 5008 KB Output is correct
22 Correct 3 ms 312 KB Output is correct
23 Correct 7 ms 304 KB Output is correct
24 Correct 191 ms 5208 KB Output is correct
25 Correct 136 ms 4964 KB Output is correct
26 Correct 145 ms 5128 KB Output is correct
27 Correct 217 ms 5012 KB Output is correct
28 Incorrect 52 ms 5620 KB Output isn't correct
29 Halted 0 ms 0 KB -