답안 #831928

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
831928 2023-08-20T17:52:40 Z rubdary 식물 비교 (IOI20_plants) C++14
0 / 100
4000 ms 4900 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++){
      |                 ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 54 ms 4076 KB Output is correct
7 Execution timed out 4082 ms 4900 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 292 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Incorrect 0 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 304 KB Output is correct
4 Incorrect 1 ms 296 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 54 ms 4076 KB Output is correct
7 Execution timed out 4082 ms 4900 KB Time limit exceeded
8 Halted 0 ms 0 KB -