Submission #301555

# Submission time Handle Problem Language Result Execution time Memory
301555 2020-09-18T04:19:44 Z Muhammetali Comparing Plants (IOI20_plants) C++11
0 / 100
386 ms 3248 KB
#include "plants.h"
#include <bits/stdc++.h>
#define mp make_pair
#define f first
#define s second
#define sz(x) (int)(x).size()
#define rsz resize
#define ins insert
#define ft front()
#define bk back()
#define pf push_front
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
int h,n,arr[200001];
void init(int k,vi r)
{
	h=k;
	n=sz(r);
	for (int i=0;i<n;i++)
	{
		arr[i]=r[i];
	}
	return;
}
int compare_plants(int x,int y)
{
	if (arr[x]==0)
	{
		int g=h-2;
		int f=x;
		while(f<y && g>=0)
		{
			f++;g--;
			if (arr[f]==0)g=h-2;
		}
		if (f==y)return 1;
	}
	else
	{
		int g=h-2;
		int f=x;
		while(f<y && g>=0)
		{
			f++;g--;
			if (arr[f]==h-1)g=h-2;
		}
		if (f==y)return -1;
	}
	if (arr[y]==h-1)
	{
		int g=h-2;
		int f=y;
		while(f<n && g>=0)
		{
			f++;g--;
			if (arr[f]==h-1)g=h-2;
		}
		if(f!=n)return 0;
		f=0;
		if (arr[f]==h-1)g=h-2;
		while(f<x && g>=0)
		{
			f++;g--;
			if (arr[f]==h-1)g=h-2;
		}
		if (f==x)return 1;
	}
	else
	{
		int g=h-2;
		int f=y;
		while(f<n && g>=0)
		{
			f++;g--;
			if (arr[f]==0)g=h-2;
		}
		if (f!=n)return 0;
		f=0;
		if (arr[f]==h-1)g=h-2;
		while(f<x && g>=0)
		{
			f++;g--;
			if (arr[f]==0)g=h-2;
		}
		if (f==x)return -1;
	}
	return 0;
}
# Verdict Execution time Memory 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 -
# Verdict Execution time Memory Grader output
1 Correct 0 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 -
# Verdict Execution time Memory Grader output
1 Correct 0 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 -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Incorrect 386 ms 3248 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 416 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Incorrect 1 ms 384 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Incorrect 1 ms 256 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory 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 -