Submission #817837

# Submission time Handle Problem Language Result Execution time Memory
817837 2023-08-09T17:43:34 Z rubdary Comparing Plants (IOI20_plants) C++14
0 / 100
1 ms 304 KB
#include "plants.h"
#include <iostream>
using namespace std;
vector <bool> plants;
 
void init(int k, vector<int> r) {
	for(int i = 0; i < r.size(); i++){
		if(r[i] == 0)
			plants.push_back(true);
		else
			plants.push_back(false);
	}
	return;
}
 
int compare_plants(int x, int y) {
	int i = x;
	bool s = plants[x];
	bool res = true;
	while(i != y){
		if(plants[i] != s) res = false;
		i++;
		i = i % plants.size();
	}
	if(res == true && s == true) return 1;
	if(res == true && s == false) return -1;
	res = true;
	i = y;
	s = plants[y];
	while(i != x){
		if(plants[i] != s) res = false;
		i++;
		i = i % plants.size();
	}
	if(res == true && s == true) return 1;
	if(res == true && s == false) return -1;
	return 0;
}

Compilation message

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