Submission #835558

# Submission time Handle Problem Language Result Execution time Memory
835558 2023-08-23T15:54:16 Z rubdary Comparing Plants (IOI20_plants) C++14
0 / 100
1 ms 296 KB
#include "plants.h"
#include <iostream>
using namespace std;
int N;
vector <int> sum;

void init(int k, vector<int> r){
	sum.push_back(0);
	for(int i = 0; i < r.size(); i++){
		sum.push_back(sum.back()+r[i]);
	}
	return;
}

int lower(int x, int y){
	int suma = sum[y] - sum[x];
	int cant = y - x + 1;
	if(suma == 0) return 1;
	if(suma == cant) return -1;
	suma = sum.back() - suma;
	cant = N - cant;
	if(suma == 0) return -1;
	if(suma == cant) return 1;
	return 0;
}
int higher(int x, int y){
	int suma = sum[x] - sum[y];
	int cant = x - y + 1;
	if(suma == 0) return -1;
	if(suma == cant) return 1;
	suma = sum.back() - suma;
	cant = N - cant;
	if(suma == 0) return 1;
	if(suma == cant) return -1;
	return 0;
}

int compare_plants(int x, int y){
	N = sum.size();
	if(x < y) return lower(x, y); 
	return higher(x, y);
}

Compilation message

plants.cpp: In function 'void init(int, std::vector<int>)':
plants.cpp:9:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 |  for(int i = 0; i < r.size(); i++){
      |                 ~~^~~~~~~~~~
# 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 296 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 212 KB Output is correct
3 Correct 1 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 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 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 Incorrect 1 ms 212 KB Output isn't correct
2 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 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 1 ms 212 KB Output is correct
3 Incorrect 1 ms 296 KB Output isn't correct
4 Halted 0 ms 0 KB -