Submission #817483

# Submission time Handle Problem Language Result Execution time Memory
817483 2023-08-09T12:53:18 Z Trumling Comparing Plants (IOI20_plants) C++14
5 / 100
62 ms 8680 KB
#include "plants.h"
#include <bits/stdc++.h>
using namespace std; 

typedef long long ll;
#define pb push_back
#define F first
#define S second
#define enter cout<<'\n';
#define INF 99999999999999999
#define MOD 1000000007
#define all(x) x.begin(),x.end()
vector<int>pre,suf;
ll nn;
void init(int k, vector<int> r) {
	pre.assign(r.size(),0);
	suf.assign(r.size(),0);
	nn=r.size();
	if(k==2)
	{
	for(int i=0;i<nn;i++)
		pre[i]=((i==0)?0:pre[i-1])+r[i];

	for(int i=nn-1;i>=0;i--)
		suf[i]=((i==nn-1)?0:suf[i+1])+r[i];
	}
	else
	{
	for(int i=0;i<nn;i++)
		pre[i]=((i==0)?0:pre[i-1])+ r[i]>=r[(i+1)%nn];

	for(int i=nn-1;i>=0;i--)
		suf[i]=((i==nn-1)?0:suf[i+1])+ r[i]>=r[(i+1)%nn];
	}

	

	return;
}
int compare_plants(int x, int y) 
{
	ll r=pre[y-1]-((x==0)?0:pre[x-1]);
	ll l= ((x==0)?0:pre[x-1])+ suf[y];
	ll ans=0;
	if(r==y-x)
		ans=-1;
	if(r==0)
		ans=1;
	if(l==nn-y+x)
		ans=1;
	if(l==0)
		ans=-1;

	return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 37 ms 4024 KB Output is correct
7 Correct 42 ms 5524 KB Output is correct
8 Correct 60 ms 8664 KB Output is correct
9 Correct 54 ms 8672 KB Output is correct
10 Correct 55 ms 8664 KB Output is correct
11 Correct 55 ms 8640 KB Output is correct
12 Correct 62 ms 8676 KB Output is correct
13 Correct 53 ms 8652 KB Output is correct
14 Correct 62 ms 8680 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 0 ms 300 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 0 ms 300 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 300 KB Output is correct
3 Correct 1 ms 304 KB Output is correct
4 Incorrect 1 ms 300 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 300 KB Output is correct
4 Incorrect 0 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 37 ms 4024 KB Output is correct
7 Correct 42 ms 5524 KB Output is correct
8 Correct 60 ms 8664 KB Output is correct
9 Correct 54 ms 8672 KB Output is correct
10 Correct 55 ms 8664 KB Output is correct
11 Correct 55 ms 8640 KB Output is correct
12 Correct 62 ms 8676 KB Output is correct
13 Correct 53 ms 8652 KB Output is correct
14 Correct 62 ms 8680 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Incorrect 0 ms 300 KB Output isn't correct
18 Halted 0 ms 0 KB -