Submission #438569

# Submission time Handle Problem Language Result Execution time Memory
438569 2021-06-28T09:03:32 Z AmineTrabelsi Comparing Plants (IOI20_plants) C++14
0 / 100
1 ms 304 KB
#include "plants.h"
#include <bits/stdc++.h>
using namespace std;
const int M = 200005;
int pref[M];
int n;
int sum(int l,int r){
	//cerr << l <<" "<<r<<endl;
	if(r < l){
		return sum(0,r)+sum(l,n-1);
	}
	return pref[r+1]-pref[l];
}
void init(int k, vector<int> r) {
	n = r.size();
	for(int i=0;i<n;i++){
		pref[i+1] = pref[i]+r[i];
	}
	return;
}
bool istaller(int x,int y){
	//cerr <<sum(x,(y > 0 ? y-1 : n-1))<<" "<<x<<" "<<(y > 0 ? y-1 : n-1)<<" "<<endl;
	if(sum(x,(y > 0 ? y-1 : n-1)) == 0)return true;
	int range = sum(0,n-1)-sum(x,y);
	if(range == n-abs(x-y)-1)return true;
	return false;
}
int compare_plants(int x, int y) {
	//cerr << 1 << endl;
	if(istaller(x,y))return 1;
	//scerr << 2 << endl;
	if(istaller(y,x))return -1;
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 300 KB Output is correct
3 Incorrect 1 ms 304 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Incorrect 1 ms 204 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Incorrect 1 ms 204 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Incorrect 1 ms 204 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Incorrect 1 ms 204 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 300 KB Output is correct
3 Incorrect 1 ms 304 KB Output isn't correct
4 Halted 0 ms 0 KB -