Submission #789701

# Submission time Handle Problem Language Result Execution time Memory
789701 2023-07-21T19:18:45 Z FEDIKUS Comparing Plants (IOI20_plants) C++17
0 / 100
1 ms 308 KB
#include "plants.h"
#include<bits/stdc++.h>

using namespace std;

const int maxn=2e5+10;

int n;
int sled[maxn]; // 1 = veci
int pref[maxn];
int uk=0;

void init(int k, vector<int> r) {
	n=r.size();
	for(int i=0;i<n;i++){
		if(r[i]==1) sled[i]=1;
		if(i>0) pref[i]=pref[i-1];
		pref[i]+=sled[i];
		uk+=sled[i];
	}
	return;
}

int qry(int l,int r){
	return pref[r]-(l>0 ? pref[l-1]:0);
}

int compare_plants(int x, int y){
	if(qry(x,y-1)==y-x) return -1;
	int ostalo=uk-qry(x,y-1);
	if(ostalo==n-y+x) return 1;
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 308 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Incorrect 1 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 304 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 304 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 304 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 308 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Incorrect 1 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 308 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Incorrect 1 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -